QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736337#6564. Frequent Flierblackpanther9229WA 10ms6744kbC++141.2kb2024-11-12 10:11:212024-11-12 10:11:23

Judging History

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

  • [2024-11-12 10:11:23]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:6744kb
  • [2024-11-12 10:11:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 210000, M = 2100000;

int n, m;

long long k;

long long a[N];

long long b[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m >> k;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
    }


    long long cur_sum = 0;
    deque<int> q;

    for (int i = 1; i <= n + m - 1; i ++) {
        while (q.front() <= i - m) {
            q.pop_front();
        }

        if (i - m > 0) {
            cur_sum -= b[i - m];
        }

        if (i <= n) {
            q.push_back(i);
        }


        while (!q.empty() && cur_sum < k) {
            int j = q.back();
            q.pop_back();

            if (cur_sum + a[j] - b[j] >= k) {
                b[j] += k - cur_sum;
                cur_sum = k;

                if (b[j] < a[j]) q.push_back(j);
            }

            else {
                cur_sum += (a[j] - b[j]);
                b[j] = a[j];
            }


        }
    }

    long long ans = 0;
    for (int i = 1; i <= n; i ++) {
        //cout << i << " : " << b[i] << "\n";
        ans += b[i];
    }

    cout << ans;


    return 0;
}



详细

Test #1:

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

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: 10ms
memory: 6744kb

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'