QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#365310 | #7845. Fast Forward | kevinyang# | WA | 1ms | 3572kb | C++17 | 1008b | 2024-03-25 02:20:20 | 2024-03-25 02:20:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int ln = 21;
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n,c;
cin >> n >> c;
vector<int>a(n*2+1);
vector<int>psa(n*2+1);
for(int i = 1; i<=n; i++){
cin >> a[i];
a[i+n] = a[i];
}
for(int i = 1; i<=2*n; i++){
psa[i] = psa[i-1] + a[i];
}
vector<vector<int>>dp(2*n+2,vector<int>(ln));
dp[2*n+1][0] = 2*n+1;
for(int i = 1; i<=2*n; i++){
int low = i;
int high = 2*n;
while(low + 1 < high){
int mid = (low+high)/2;
if(psa[mid]-psa[i-1] >= c){
high = mid;
}
else{
low = mid;
}
}
dp[i][0] = high+1;
}
for(int j = 1; j<ln; j++){
for(int i = 1; i<=2*n+1; i++){
dp[i][j] = dp[dp[i][j-1]][j-1];
}
}
for(int i = 1; i<=n; i++){
int ans = 0;
int u = i;
for(int j = ln-1; j>=0; j--){
if(dp[u][j]<i+n){
u = dp[u][j];
ans+=1<<j;
}
}
cout << ans;
if(i<n)cout << ' ';
}
cout << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3484kb
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: 1ms
memory: 3572kb
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: 3536kb
input:
10 5 4 1 5 5 1 3 2 1 5 2
output:
4 4 4 4 4 4 4 4 4 4
result:
wrong answer 1st lines differ - expected: '5 4 5 4 4 5 4 4 5 4', found: '4 4 4 4 4 4 4 4 4 4'