QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#117649#6630. Triangle Collectionsomethingnew#0 13ms3636kbC++232.1kb2023-07-01 21:38:552024-05-31 18:46:48

Judging History

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

  • [2024-05-31 18:46:48]
  • 评测
  • 测评结果:0
  • 用时:13ms
  • 内存:3636kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-01 21:38:55]
  • 提交

answer

//  ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
//  ➡ @roadfromroi ⬅
//  ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#include "queue"
#define all(x) x.begin(), x.end()
using namespace std;
#define int long long
void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n), ac;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < q; ++i) {
        int x, c;
        cin >> x >> c;
        x--;
        queue<pair<int, int>> que;
        a[x] += c;
        ac = a;
        int lft = 0;
        int res = 0;
        for (int j = 0; j < n; ++j) {
            if (j % 2 == 1 and !que.empty() and que.front().first == j / 2) {
                int pt = que.front().second * 2 / 3;
                res += pt;
                lft += que.front().second * 2 % 3;
                que.pop();
                while (!que.empty() and lft != 0) {
                    int vl = min(que.front().second, lft);
                    que.front().second -= vl;
                    lft -= vl;
                    res += vl;
                    if (que.front().second == 0)
                        que.pop();
                }
            }
            int qq = min(lft, a[j] / 2);
            lft -= qq;
            a[j] -= qq * 2;
            res += qq;
            if (a[j] >= 2) {
                que.push({j, a[j] / 2});
                a[j] %= 2;
            }
            if (a[j]) {
                if (!que.empty()) {
                    que.front().second--;
                    if (que.front().second == 0)
                        que.pop();
                    res++;
                } else {
                    lft++;
                }
            }
        }
        cout << res << '\n';
        a = ac;
    }
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    while (t--) {
        solve();
    }
}
/*
4 3
3 1 4 1
3 -3
1 6
2 1
 */

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3568kb

input:

1 23
1485
1 -12
1 -30
1 -20
1 6
1 24
1 5
1 31
1 14
1 -34
1 -22
1 -45
1 37
1 46
1 9
1 22
1 -9
1 9
1 -46
1 -47
1 39
1 36
1 -36
1 50

output:

1
1
1
1
1
0
1
1
1
1
0
1
1
0
0
1
0
0
1
0
0
0
0

result:

wrong answer 1st numbers differ - expected: '491', found: '1'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #28:

score: 0
Wrong Answer
time: 13ms
memory: 3636kb

input:

1999 2000
1 1 1 1 0 2 0 2 1 0 2 1 2 2 2 1 2 0 0 1 2 2 0 1 0 1 0 2 0 0 2 1 1 1 1 0 1 2 1 2 1 1 1 1 1 0 2 2 0 2 1 1 2 0 0 2 0 0 2 1 2 0 0 1 1 2 0 2 2 2 1 2 0 2 1 2 0 1 2 2 2 1 1 2 1 1 1 1 0 0 1 1 0 1 2 1 0 0 2 0 2 2 2 0 1 1 2 0 0 1 0 0 2 1 2 1 2 0 1 1 2 2 0 0 1 2 2 1 2 1 2 2 2 0 0 1 1 2 1 1 2 2 2 2 2 ...

output:

660
660
660
661
661
661
661
660
660
660
660
661
662
662
663
663
662
661
662
662
661
660
661
660
660
660
661
661
661
661
662
661
661
660
661
660
659
658
658
659
659
658
659
660
660
660
660
660
660
659
659
659
659
659
659
659
659
660
659
658
658
658
658
657
657
657
658
657
656
657
657
657
656
656
655
...

result:

wrong answer 1664th numbers differ - expected: '666', found: '664'

Subtask #4:

score: 0
Wrong Answer

Test #35:

score: 0
Wrong Answer
time: 10ms
memory: 3508kb

input:

2000 1999
0 1 0 3 0 1 0 0 0 0 0 0 0 2 0 0 0 0 3 1 1 0 2 0 0 3 0 0 0 0 0 4 0 0 1 0 1 0 0 0 0 1 2 1 0 0 0 0 7 0 1 3 1 0 1 1 0 3 2 1 0 1 1 3 3 1 0 2 0 0 0 0 0 0 0 0 1 0 0 0 2 0 0 0 0 0 1 2 3 0 1 0 3 3 0 0 0 0 1 0 1 2 0 0 2 2 0 1 2 1 2 0 0 0 1 1 0 1 2 0 0 0 0 2 0 5 0 0 0 0 0 1 0 0 2 0 1 2 0 1 0 0 0 2 0 ...

output:

659
660
659
660
659
660
659
660
659
658
657
658
657
656
655
656
657
658
657
656
655
656
657
658
659
660
661
662
663
662
661
662
661
662
661
662
663
662
663
664
665
666
666
666
665
665
665
665
665
665
665
665
665
665
665
665
665
665
665
665
665
666
666
666
665
664
663
662
663
664
663
664
663
664
663
...

result:

wrong answer 1st numbers differ - expected: '666', found: '659'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%