QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#175258 | #6564. Frequent Flier | SolitaryDream# | RE | 1ms | 3672kb | C++17 | 888b | 2023-09-10 17:04:34 | 2023-09-10 17:04:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
const int N=1e5+1e3+7;
int n,m,k,use[N];
set<pii> s;
int main()
{
scanf("%d%d%d",&n,&m,&k);
long long ans=0;
int tot=0;
for(int i=1;i<=n+m-1;i++)
{
int x=0;
if(i<=n)
scanf("%d",&x);
s.insert({i,x});
if(i-m>0)
tot-=use[i-m];
if(s.size()&&s.begin()->first<=i-m)
s.erase(s.begin());
int r=k-tot;
while(r)
{
if(!s.size())
break;
auto [id,w]=*s.rbegin();
s.erase(prev(s.end()));
int t=min(w,r);
r-=t;
w-=t;
use[id]+=t;
if(w)
s.insert({id,w});
ans+=t;
tot+=t;
}
}
printf("%lld\n",ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3672kb
input:
8 3 2 3 1 4 1 5 9 2 6
output:
8
result:
ok single line: '8'
Test #2:
score: -100
Runtime Error
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...