QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#268567#7845. Fast ForwardYarema#WA 0ms3816kbC++141.3kb2023-11-28 18:32:062023-11-28 18:32:07

Judging History

你现在查看的是最新测评结果

  • [2023-11-28 18:32:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3816kb
  • [2023-11-28 18:32:06]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const int N = 1'000'447;
const int LOG = 20;

int up[N][LOG];

int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	cout << fixed << setprecision(15);
	
	int n, k;
	cin >> n >> k;
	vector<LL> a(n);
	vector<LL> pref(2 * n + 1);
	
	FOR (i, 0, n)
	{
		cin >> a[i];
		pref[i + 1] = a[i];
		pref[n + i + 1] = a[i];
	}
	FOR (i, 0, 2 * n)
		pref[i + 1] += pref[i];
	
	FOR (i, 0, 2 * n + 1)
	{
		int to = upper_bound(ALL(pref), pref[i] + k) - pref.begin();
		up[i][0] = to;
	}
	up[2 * n + 1][0] = 2 * n + 1;
	FOR (i, 1, LOG)
	{
		FOR (j, 0, 2 * n + 2)
		{
			up[j][i] = up[up[j][i - 1]][i - 1];
		}
	}
	FOR (i, 0, n)
	{
		int ans = 0;
		int idx = i;
		RFOR (j, LOG, 0)
		{
			if (up[idx][j] < i + n)
			{
				idx = up[idx][j];
				ans += 1 << j;
			}
		}
		if (i)
			cout << ' ';
		cout << ans;
	}
	cout << '\n';
	
	
	
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3816kb

input:

7 7
1 1 1 1 1 1 1

output:

0 0 0 0 0 0 0

result:

ok single line: '0 0 0 0 0 0 0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

3 3
1 1 3

output:

0 1 1

result:

ok single line: '0 1 1'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

10 5
4 1 5 5 1 3 2 1 5 2

output:

3 4 4 3 4 3 4 4 3 4

result:

wrong answer 1st lines differ - expected: '5 4 5 4 4 5 4 4 5 4', found: '3 4 4 3 4 3 4 4 3 4'