QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#792389 | #6564. Frequent Flier | lukamosiashvili# | TL | 0ms | 7756kb | C++17 | 921b | 2024-11-29 09:48:57 | 2024-11-29 09:48:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
long long a[400009], ans, lf[400009], org_a[400009];
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int n, m, k;
cin >> n >> m >> k;
for(int i = 1; i <= n; i++){
cin >> a[i];
org_a[i] = a[i];
lf[i] = i;
}
long long sum = k;
for(int i = 1; i <= n + m - 1; i++){
int j = i;
while(sum > 0 && j > i - m){
if(a[j] > sum){
a[j] -= sum;
ans += sum;
sum = 0;
break;
}
sum -= a[j];
ans += a[j];
a[j] = 0;
lf[i] = lf[j - 1];
j = lf[j - 1];
}
//cout << i << " " << ans << endl;
if(i - m + 1 >= 1) sum += org_a[i - m + 1] - a[i - m + 1];
}
cout << ans;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 7756kb
input:
8 3 2 3 1 4 1 5 9 2 6
output:
8
result:
ok single line: '8'
Test #2:
score: -100
Time Limit Exceeded
input:
200000 2467 999931035 182548858 69876218 33328350 919486767 739850600 948199964 392292320 39077742 366752074 917496841 246661698 37219034 56677740 188278971 965701828 28059790 13200243 825730775 542597589 320715170 939054378 470563899 914247467 990100491 290827128 903662394 611104879 18631185 412134...