Submission #25592255
Source Code Expand
#include <bits/stdc++.h>
#define PI 3.14159265359
#define lp(i, n) for (size_t i = 0; i < n; i++)
typedef long long ll;
typedef long double ld;
using namespace std;
const char nl = '\n';
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll l, q;
cin >> l >> q;
set<ll> cuts;
set<ll, greater<ll>> great;
cuts.insert(0);
cuts.insert(l);
great.insert(0);
great.insert(l);
lp(i, q) {
ll c, x;
cin >> c >> x;
if (c == 1) {
cuts.insert(x);
great.insert(x);
} else {
using it = set<ll>::iterator;
it l = great.upper_bound(x);
it r = cuts.upper_bound(x);
/* cout << *l << nl; */
/* cout << *r << nl; */
cout << *r - *l << nl;
}
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Cutting Woods |
| User | alabh |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 890 Byte |
| Status | AC |
| Exec Time | 232 ms |
| Memory | 22228 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:3:39: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘ll’ {aka ‘long long int’} [-Wsign-compare]
3 | #define lp(i, n) for (size_t i = 0; i < n; i++)
......
23 | lp(i, q) {
| ~~~~
./Main.cpp:23:5: note: in expansion of macro ‘lp’
23 | lp(i, q) {
| ^~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| 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 | 7 ms | 3504 KiB |
| 00_sample_01.txt | AC | 1 ms | 3656 KiB |
| 00_sample_02.txt | AC | 2 ms | 3588 KiB |
| 01_max_random_00.txt | AC | 153 ms | 13004 KiB |
| 01_max_random_01.txt | AC | 180 ms | 12836 KiB |
| 01_max_random_02.txt | AC | 152 ms | 13000 KiB |
| 01_max_random_03.txt | AC | 160 ms | 12964 KiB |
| 01_max_random_04.txt | AC | 171 ms | 12944 KiB |
| 02_all_1_00.txt | AC | 232 ms | 22184 KiB |
| 03_all_2_00.txt | AC | 54 ms | 3624 KiB |
| 04_hack_00.txt | AC | 136 ms | 22136 KiB |
| 04_hack_01.txt | AC | 133 ms | 22228 KiB |
| 04_hack_02.txt | AC | 137 ms | 12940 KiB |
| 04_hack_03.txt | AC | 131 ms | 12992 KiB |
| 04_hack_04.txt | AC | 140 ms | 12896 KiB |