Submission #38460075
Source Code Expand
// Think twice, code once.
#include <set>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
int q,l,r;
multiset<int>s;
signed main() {
scanf("%lld%lld%lld",&q,&l,&r);
s.insert(l-r),s.insert(l+r);
while (q--) {
int op;
scanf("%lld%lld%lld",&op,&l,&r);
if (op==1) s.insert(l-r),s.insert(l+r);
else {
if (r<*s.begin()) printf("%lld\n",*s.begin()-r);
else if (*s.rbegin()<l) printf("%lld\n",l-*s.rbegin());
else {
auto it=s.lower_bound(l);
if (*it<=r) puts("0");
else printf("%lld\n",min(l-*prev(it),*it-r));
}
}
}
return 0;
}
Submission Info
Submission Time
2023-01-29 22:23:50+0900
Task
B - Abs Abs Function
User
CaijiMK
Language
C++ (GCC 9.2.1)
Score
500
Code Size
683 Byte
Status
AC
Exec Time
239 ms
Memory
20608 KiB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:15:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
15 | scanf("%lld%lld%lld",&q,&l,&r);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
./Main.cpp:19:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
19 | scanf("%lld%lld%lld",&op,&l,&r);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
500 / 500
Status
Set Name
Test Cases
Sample
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_rand1_01.txt, 01_rand1_02.txt, 01_rand1_03.txt, 01_rand1_04.txt, 01_rand1_05.txt, 01_rand1_06.txt, 01_rand1_07.txt, 01_rand1_08.txt, 01_rand1_09.txt, 01_rand1_10.txt, 01_rand1_11.txt, 01_rand1_12.txt, 01_rand1_13.txt, 01_rand1_14.txt, 02_rand2_01.txt, 02_rand2_02.txt, 02_rand2_03.txt, 02_rand2_04.txt, 02_rand2_05.txt, 02_rand2_06.txt, 02_rand2_07.txt, 02_rand2_08.txt, 02_rand2_09.txt, 02_rand2_10.txt, 02_rand2_11.txt, 02_rand2_12.txt, 02_rand2_13.txt, 02_rand2_14.txt, 02_rand2_15.txt, 03_test_01.txt, 03_test_02.txt
Case Name
Status
Exec Time
Memory
00_sample_01.txt
AC
4 ms
3672 KiB
00_sample_02.txt
AC
2 ms
3564 KiB
00_sample_03.txt
AC
2 ms
3572 KiB
01_rand1_01.txt
AC
215 ms
13124 KiB
01_rand1_02.txt
AC
200 ms
13132 KiB
01_rand1_03.txt
AC
202 ms
13004 KiB
01_rand1_04.txt
AC
201 ms
13048 KiB
01_rand1_05.txt
AC
203 ms
12992 KiB
01_rand1_06.txt
AC
201 ms
13044 KiB
01_rand1_07.txt
AC
201 ms
13048 KiB
01_rand1_08.txt
AC
214 ms
12936 KiB
01_rand1_09.txt
AC
224 ms
13052 KiB
01_rand1_10.txt
AC
223 ms
13000 KiB
01_rand1_11.txt
AC
220 ms
12948 KiB
01_rand1_12.txt
AC
216 ms
13060 KiB
01_rand1_13.txt
AC
215 ms
13108 KiB
01_rand1_14.txt
AC
205 ms
13112 KiB
02_rand2_01.txt
AC
151 ms
12936 KiB
02_rand2_02.txt
AC
161 ms
13004 KiB
02_rand2_03.txt
AC
155 ms
13044 KiB
02_rand2_04.txt
AC
145 ms
13004 KiB
02_rand2_05.txt
AC
145 ms
13052 KiB
02_rand2_06.txt
AC
143 ms
12880 KiB
02_rand2_07.txt
AC
199 ms
13052 KiB
02_rand2_08.txt
AC
196 ms
13000 KiB
02_rand2_09.txt
AC
199 ms
13004 KiB
02_rand2_10.txt
AC
137 ms
20608 KiB
02_rand2_11.txt
AC
136 ms
20376 KiB
02_rand2_12.txt
AC
137 ms
20552 KiB
02_rand2_13.txt
AC
234 ms
20376 KiB
02_rand2_14.txt
AC
239 ms
20432 KiB
02_rand2_15.txt
AC
237 ms
20556 KiB
03_test_01.txt
AC
6 ms
3684 KiB
03_test_02.txt
AC
205 ms
12928 KiB