QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#188922 | #6564. Frequent Flier | ucup-team870# | WA | 14ms | 7244kb | C++14 | 857b | 2023-09-26 16:49:18 | 2023-09-26 16:49:18 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<=r; i++)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int N = 400020;
int a[N], b[N], st[N], top, rem[N];
int main() {
int n, m, k; scanf("%d%d%d", &n, &m, &k);
rep (i, 1, n) {
scanf("%d", &a[i]);
rem[i] = a[i];
}
int now = 0;
ll ans = 0;
rep (i, 1, n+m-1) {
if (i - m >= 1) {
now -= b[i-m];
}
st[++top] = i;
while (top && now < k) {
int tmp = min(k - now, rem[st[top]]);
rem[st[top]] -= tmp;
b[st[top]] += tmp;
if (rem[st[top]]== 0) top--;
now += tmp;
ans += tmp;
}
}
cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3828kb
input:
8 3 2 3 1 4 1 5 9 2 6
output:
8
result:
ok single line: '8'
Test #2:
score: -100
Wrong Answer
time: 14ms
memory: 7244kb
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...
output:
83896397570
result:
wrong answer 1st lines differ - expected: '82994275905', found: '83896397570'