QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#515923 | #7845. Fast Forward | feng | WA | 0ms | 3628kb | C++20 | 1.3kb | 2024-08-12 11:35:19 | 2024-08-12 11:35:19 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define ll long long
#define PII std::pair<int,int>
using namespace std;
const int maxn = 1e6 + 5;
int nex[maxn][25];
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
cout << fixed << setprecision(2);
int n, c; cin >> n >> c;
int dn = n * 2;
vector<int> d(dn + 1);
for (int i = 0; i < n; ++i) {
cin >> d[i];
d[n + i - 1] = d[i];
}
int sum = 0;
for (int i = 0; i < n; ++i) {
sum += d[i];
}
if (c >= sum) {
for (int i = 0; i < n; ++i) {
cout << "0" << " ";
}
return 0;
}
int l = 0, r = 0;
sum = 0;
while (l < dn) {
while (r < dn && sum < c) sum += d[r++];
nex[l][0] = r;
sum -= d[l++];
}
for (int j = 0; j <= 20; ++j) nex[dn][j] = dn;
for (int i = dn - 1; i >= 0; --i) {
for (int j = 1; j <= 20; ++j) {
nex[i][j] = nex[nex[i][j - 1]][j - 1];
}
}
for (int i = 0; i < n; ++i) {
int ans = 0, cur = i;
for (int j = 20; j >= 0; --j) {
if (nex[cur][j] - i < n) {
ans |= 1 << j;
cur = nex[cur][j];
}
}
cout << ans << " ";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
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: 3532kb
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: 3628kb
input:
10 5 4 1 5 5 1 3 2 1 5 2
output:
5 4 4 4 4 4 3 4 4 4
result:
wrong answer 1st lines differ - expected: '5 4 5 4 4 5 4 4 5 4', found: '5 4 4 4 4 4 3 4 4 4 '