QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#349015#6564. Frequent Flierrealcomplex0#WA 47ms14444kbC++201.3kb2024-03-09 23:02:452024-03-09 23:02:45

Judging History

你现在查看的是最新测评结果

  • [2024-03-09 23:02:45]
  • 评测
  • 测评结果:WA
  • 用时:47ms
  • 内存:14444kb
  • [2024-03-09 23:02:45]
  • 提交

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");
    int n, m, k;
    cin >> n >> m >> k;
    set<int> s;
    int f[n+1], taken[n+1];
    memset(taken,0,sizeof(taken));
    for(int i = 1;i<=n;i++)
    {
        cin >> f[i];
        s.insert(i);
    }
    ll res = 0;
    int cur = 0;
    for(int 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;
            int 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(int i = 0;i<n&&cur<k;i++)
    {
        if(cur+f[i]<=k)
            res+=f[i]-taken[i];
        else
        {
            int 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: 0ms
memory: 3500kb

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: 47ms
memory: 14444kb

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: 0ms
memory: 3500kb

input:

1 200000 999959273
1255319

output:

-587503673

result:

wrong answer 1st lines differ - expected: '1255319', found: '-587503673'