Submission #71009031


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int main () {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int64_t> d(n-1, 1);
  vector<int64_t> a(n);
  for (int i = 0; i < q; i++) {
    int j, x;
    cin >> j >> x;
    j--;
    a[j] += x;
    if (j) d[j-1] = max(d[j-1], a[j-1]-a[j]+1);
    if (j < n-1) d[j] = max(d[j], a[j]-a[j+1]+1);
  }
  int64_t ans = 1, cur = 1;
  for (auto& x: d) ans += (cur += x);
  cout << ans << '\n';
}

Submission Info

Submission Time
Task A - Always Increasing
User AndrewG
Language C++23 (GCC 15.2.0)
Score 300
Code Size 490 Byte
Status AC
Exec Time 22 ms
Memory 6600 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 38
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_rand_01.txt, 02_rand_02.txt, 02_rand_03.txt, 02_rand_04.txt, 02_rand_05.txt, 02_rand_06.txt, 02_rand_07.txt, 02_rand_08.txt, 02_rand_09.txt, 02_rand_10.txt, 03_maxrand_01.txt, 03_maxrand_02.txt, 03_maxrand_03.txt, 03_maxrand_04.txt, 03_maxrand_05.txt, 03_maxrand_06.txt, 03_maxrand_07.txt, 03_maxrand_08.txt, 03_maxrand_09.txt, 03_maxrand_10.txt, 04_maxrand_skew_01.txt, 04_maxrand_skew_02.txt, 04_maxrand_skew_03.txt, 04_maxrand_skew_04.txt, 04_maxrand_skew_05.txt, 04_maxrand_skew_06.txt, 04_maxrand_skew_07.txt, 04_maxrand_skew_08.txt, 04_maxrand_skew_09.txt, 04_maxrand_skew_10.txt, 05_maxans_01.txt, 05_maxans_02.txt, 05_maxans_03.txt, 05_maxans_04.txt, 05_maxans_05.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 8 ms 3448 KiB
01_sample_02.txt AC 1 ms 3400 KiB
01_sample_03.txt AC 2 ms 4976 KiB
02_rand_01.txt AC 2 ms 4112 KiB
02_rand_02.txt AC 9 ms 4860 KiB
02_rand_03.txt AC 9 ms 4592 KiB
02_rand_04.txt AC 11 ms 5364 KiB
02_rand_05.txt AC 14 ms 5832 KiB
02_rand_06.txt AC 13 ms 3552 KiB
02_rand_07.txt AC 12 ms 3592 KiB
02_rand_08.txt AC 12 ms 3532 KiB
02_rand_09.txt AC 12 ms 3752 KiB
02_rand_10.txt AC 16 ms 4920 KiB
03_maxrand_01.txt AC 22 ms 6424 KiB
03_maxrand_02.txt AC 20 ms 6512 KiB
03_maxrand_03.txt AC 21 ms 6464 KiB
03_maxrand_04.txt AC 20 ms 6312 KiB
03_maxrand_05.txt AC 21 ms 6512 KiB
03_maxrand_06.txt AC 21 ms 6536 KiB
03_maxrand_07.txt AC 21 ms 6464 KiB
03_maxrand_08.txt AC 22 ms 6600 KiB
03_maxrand_09.txt AC 21 ms 6440 KiB
03_maxrand_10.txt AC 21 ms 6340 KiB
04_maxrand_skew_01.txt AC 14 ms 6456 KiB
04_maxrand_skew_02.txt AC 15 ms 6376 KiB
04_maxrand_skew_03.txt AC 16 ms 6396 KiB
04_maxrand_skew_04.txt AC 17 ms 6536 KiB
04_maxrand_skew_05.txt AC 16 ms 6416 KiB
04_maxrand_skew_06.txt AC 15 ms 6452 KiB
04_maxrand_skew_07.txt AC 15 ms 6516 KiB
04_maxrand_skew_08.txt AC 16 ms 6456 KiB
04_maxrand_skew_09.txt AC 16 ms 6452 KiB
04_maxrand_skew_10.txt AC 16 ms 6456 KiB
05_maxans_01.txt AC 13 ms 6476 KiB
05_maxans_02.txt AC 13 ms 6600 KiB
05_maxans_03.txt AC 13 ms 6464 KiB
05_maxans_04.txt AC 13 ms 6380 KiB
05_maxans_05.txt AC 13 ms 6516 KiB