Submission #28067089


Source Code Expand

#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;

int main()
{
  ll l, q;
  cin >> l >> q;

  set<ll> s;
  s.insert(0);
  s.insert(l);

  for (int i = 0; i < q; i++){
    int c;
    ll x;
    cin >> c >> x;
    if (c == 1){
      s.insert(x);
    } else {
      auto it = s.upper_bound(x);
      ll right = *it;
      ll left = *prev(it);
      cout << (right - left) << endl;
    }
  }
  
  return 0;
}

Submission Info

Submission Time
Task D - Cutting Woods
User unnohideyuki
Language C++ (GCC 9.2.1)
Score 400
Code Size 563 Byte
Status AC
Exec Time 382 ms
Memory 12900 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 15
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_max_random_00.txt, 01_max_random_01.txt, 01_max_random_02.txt, 01_max_random_03.txt, 01_max_random_04.txt, 02_all_1_00.txt, 03_all_2_00.txt, 04_hack_00.txt, 04_hack_01.txt, 04_hack_02.txt, 04_hack_03.txt, 04_hack_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 6 ms 3612 KiB
00_sample_01.txt AC 3 ms 3456 KiB
00_sample_02.txt AC 2 ms 3568 KiB
01_max_random_00.txt AC 290 ms 8280 KiB
01_max_random_01.txt AC 287 ms 8184 KiB
01_max_random_02.txt AC 285 ms 8132 KiB
01_max_random_03.txt AC 286 ms 8336 KiB
01_max_random_04.txt AC 286 ms 8196 KiB
02_all_1_00.txt AC 149 ms 12808 KiB
03_all_2_00.txt AC 382 ms 3616 KiB
04_hack_00.txt AC 124 ms 12732 KiB
04_hack_01.txt AC 130 ms 12900 KiB
04_hack_02.txt AC 272 ms 8136 KiB
04_hack_03.txt AC 269 ms 8140 KiB
04_hack_04.txt AC 278 ms 8336 KiB