QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#165482 | #6564. Frequent Flier | PhantomThreshold# | RE | 16ms | 8484kb | C++20 | 907b | 2023-09-05 18:37:43 | 2023-09-05 18:37:43 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
const int maxn = 210000;
int n,m,K;
int a[maxn],b[maxn];
int fa[maxn];
int findfa(const int x){ return fa[x]==x?x:fa[x]=findfa(fa[x]); }
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m>>K;
for(int i=1;i<=n;i++)
{
cin>>a[i];
fa[i]=i;
}
for(int i=n+1;i<=n+m;i++) fa[i]=i;
int sum=0;
for(int i=1;i<=n+m-1;i++)
{
if(i-m>0) sum-=b[i-m];
if(sum<K)
{
int j=findfa(i);
while(j>0 && j>i-m && sum<K)
{
int cc= min( a[j]-b[j], K-sum );
b[j]+=cc;
sum+=cc;
if(a[j]==b[j]) fa[j]=j-1;
j=findfa(j);
}
}
}
// cerr<<"---------------\n";
int ans=0;
for(int i=1;i<=n;i++)
{
ans+=b[i];
// cout<<b[i]<<endl;
}
// cerr<<"---------------\n";
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5704kb
input:
8 3 2 3 1 4 1 5 9 2 6
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 16ms
memory: 8484kb
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:
82994275905
result:
ok single line: '82994275905'
Test #3:
score: 0
Accepted
time: 2ms
memory: 8364kb
input:
1 200000 999959273 1255319
output:
1255319
result:
ok single line: '1255319'
Test #4:
score: -100
Runtime Error
input:
200000 118880 996878327 993340390 999483057 808153702 337349872 863222189 7495963 995920883 12950768 958082368 993215196 967152406 1388062 949959944 836952150 964071667 5291 139115263 958470154 51295691 175385 925242139 995685554 10895812 12563 55482 479983443 42805 996241239 6228013 302633329 10331...