QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#349017 | #6564. Frequent Flier | realcomplex0# | WA | 55ms | 16060kb | C++20 | 1.3kb | 2024-03-09 23:03:24 | 2024-03-09 23:03:24 |
Judging History
answer
#include <bits/stdc++.h>
#define en cin.close();return 0;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
// ifstream cin("in.in");
ll n, m, k;
cin >> n >> m >> k;
set<ll> s;
ll f[n+1], taken[n+1];
memset(taken,0,sizeof(taken));
for(ll i = 1;i<=n;i++)
{
cin >> f[i];
s.insert(i);
}
ll res = 0;
ll cur = 0;
for(ll i = n;i>0;i--)
{
if(i+m<=n)
cur-=taken[i+m];
while(cur<k)
{
auto t = s.lower_bound(i);
if(t==s.end())
break;
ll pos = *t, need = k-cur, take = min(need,f[pos]-taken[pos]);
taken[pos]+=take;
cur+=take;
res+=take;
if(f[pos]==taken[pos])
s.erase(pos);
}
}
cur = 0;
for(ll i = 0;i<n&&cur<k;i++)
{
if(cur+f[i]<=k)
res+=f[i]-taken[i];
else
{
ll need = k-cur;
if(need>taken[i])
res+=need-taken[i];
}
cur+=f[i];
}
cout << res;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3756kb
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: 55ms
memory: 16060kb
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: -100
Wrong Answer
time: 1ms
memory: 3532kb
input:
1 200000 999959273 1255319
output:
1001214592
result:
wrong answer 1st lines differ - expected: '1255319', found: '1001214592'