QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#400242#6630. Triangle CollectionSorahISA0 14ms3844kbC++202.1kb2024-04-27 07:42:582024-04-27 07:42:59

Judging History

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

  • [2024-04-27 07:42:59]
  • 评测
  • 测评结果:0
  • 用时:14ms
  • 内存:3844kb
  • [2024-04-27 07:42:58]
  • 提交

answer

#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA

void solve() {
    int N, Q; cin >> N >> Q;
    
    vector<int> C(N+1);
    for (int i = 1; i <= N; ++i) cin >> C[i];
    
    for (int q = 1; q <= Q; ++q) {
        int l, d; cin >> l >> d, C[l] += d;
        
        int ans = 0;
        for (int i = 1, j = 0, sum = 0; i <= N; ++i) {
            while (j+1 <= min(N, 2*i-1)) { if (C[++j] & 1) --C[j], ++sum; }
            int tmp = min(C[i] / 2, (C[i] + sum) / 3);
            // debug(i, sum, tmp);
            ans += tmp, sum = C[i] + sum - 3 * tmp;
        }
        cout << ans << "\n";
    }
}

int32_t main() {
    fastIO();
    
    int t = 1; // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        solve();
    }
    
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
#define int i64
using f80 = long double;
#define double f80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;

#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())

#ifdef local
#define fastIO() void()
#define debug(...) \
    fprintf(stderr, "\u001b[33m"), \
    fprintf(stderr, "At [%s], line %d: (%s) = ", __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), \
    fprintf(stderr, "\u001b[0m")
template <typename T> void _do(T &&_t) { cerr << _t << "\n"; }
template <typename T, typename ...U> void _do(T &&_t, U &&..._u) { cerr << _t << ", ", _do(_u...); }
#else
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(...) void()
#endif

template <typename T, typename U> bool chmin(T &lhs, U rhs) { return lhs > rhs ? lhs = rhs, 1 : 0; }
template <typename T, typename U> bool chmax(T &lhs, U rhs) { return lhs < rhs ? lhs = rhs, 1 : 0; }

#endif

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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:

491
480
474
476
484
485
495
500
488
481
466
478
493
496
503
500
503
487
471
484
496
484
500

result:

wrong answer 2nd numbers differ - expected: '481', found: '480'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #28:

score: 0
Wrong Answer
time: 14ms
memory: 3644kb

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
439
439
439
439
439
439
439
439
438
438
438
439
438
438
438
437
437
437
436
436
435
435
434
434
434
435
435
434
434
434
434
434
433
434
433
432
432
432
432
432
431
431
431
431
431
431
431
430
429
429
429
429
429
429
429
428
429
428
427
427
427
427
426
426
425
425
424
424
424
424
424
423
423
423
...

result:

wrong answer 2nd numbers differ - expected: '660', found: '439'

Subtask #4:

score: 0
Wrong Answer

Test #35:

score: 0
Wrong Answer
time: 14ms
memory: 3844kb

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:

666
447
446
446
445
445
445
445
444
444
443
443
443
443
442
442
441
441
441
441
440
440
439
439
439
439
438
438
437
437
437
437
436
436
435
435
435
434
434
434
433
433
433
433
432
432
431
431
430
430
430
429
429
429
429
428
427
427
427
427
427
427
426
426
425
425
425
424
424
424
423
423
423
422
421
...

result:

wrong answer 2nd numbers differ - expected: '666', found: '447'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%