QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124713#6564. Frequent FlierSommohito#WA 13ms12480kbC++201.7kb2023-07-15 14:26:112023-07-15 14:26:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 14:26:15]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:12480kb
  • [2023-07-15 14:26:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef APURBA
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define ALL(x) x.begin(),x.end()
#define int ll
typedef pair<int,int> pii;

int32_t main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int n,m,k;
    cin>>n>>m>>k;
    vector<int>a(n+m+m-2);
    for(int i=m-1; i<n+m-1; i++)
    {
        cin>>a[i];
    }
    int sz = n+m+m-2;
    vector<pii>st;
    vector<int>nisi(sz);
    for(int i=0; i<m; i++)
    {
        if(a[i])
            st.push_back({a[i],i});
    }
    int sum = 0;
    ll ans = 0;
    for(int i=m-1; i<sz; i++)
    {
        if(i==m-1)
        {

        }
        else
        {
            st.push_back({a[i],i});
            sum -= nisi[i-m];
        }
        debug(i,sum,nisi);
        while(st.size())
        {
            if(sum >= k)
                break;
            if(st.back().first == 0)
            {
                st.pop_back();
                continue;
            }
            if(st.back().first + sum <= k)
            {
                sum += st.back().first;
                nisi[st.back().second] += st.back().first;
                st.pop_back();
            }
            else{
                ll baki = k - sum;
                st.back().first -= baki;
                assert(st.back().first >= 0);
                nisi[st.back().second] += baki;
                sum = k;
            }
        }

    }
    debug(nisi);
    for(int i=0;i<sz;i++)
        ans += nisi[i];
    cout<<ans<<"\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3436kb

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: 13ms
memory: 12480kb

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:

83896397570

result:

wrong answer 1st lines differ - expected: '82994275905', found: '83896397570'