比赛 期末考试1 评测结果 TTTTTTTWTT
题目名称 Interactive 最终得分 0
用户昵称 赵飞羽 运行时间 9.974 s
代码语言 C++ 内存使用 4.56 MiB
提交时间 2026-02-08 10:59:47
显示代码纯文本
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 200010;
int n, k, a[N], q, x, ans;

signed main() {
    freopen("tioj_interactive.in", "r", stdin);
    freopen("tioj_interactive.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
	    cin >> a[i];
	    a[i] += a[i-1];
    }
	if (k <= 0) ans = (n + 1) * n / 2;
	cin >> q;
	while (q--) {
	    cin >> x;
	    if (k > 0) {
	        ans = 0;
	        for (int i = 1; i <= n; i++) {
	            for (int j = i; j - i + 1 <= x; j++) {
	                for (int p = i; p <= j; p++) {
	                    for (int l = p; l <= j; l++) {
	                        if (a[l] - a[p-1] >= k) {
	                            ans++;
	                            p = n + 1;
	                            break;
                            }
                        }
                    }
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}