QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#599936 | #6564. Frequent Flier | Forever_Young# | WA | 11ms | 5788kb | C++23 | 873b | 2024-09-29 13:25:28 | 2024-09-29 13:25:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define data dataa
using LL=long long;
using ULL=unsigned long long;
using LD=long double;
int f[200010],use[200010],n,m,k,stk[200010],top;
int main()
{
scanf("%d%d%d",&n,&m,&k);
rep(i,n)scanf("%d",&f[i]);
use[1]=min(f[1],k);
LL ans=use[1];
int now=use[1];
if(use[1]<f[1])stk[top=1]=1;
f[n+1]=f[n+2]=0;n+=2;
for(int i=2;i<=n;i++)
{
if(i-m>=1)now-=use[i-m];
stk[++top]=i;
for(;now<k&&top&&stk[top]>i-m;)
{
int tmp=min(k-now,f[stk[top]]-use[stk[top]]);
ans+=tmp;
now+=tmp;
use[stk[top]]+=tmp;
if(use[stk[top]]==f[stk[top]])top--;
}
}
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
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: 11ms
memory: 5788kb
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:
81994344870
result:
wrong answer 1st lines differ - expected: '82994275905', found: '81994344870'