Submission #49148422
Source Code Expand
// LUOGU_RID: 142262751
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)
#ifdef EXODUS
#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define Debug(...) 0
#endif
//=========================================================================================================
// Something about IO
template<typename T>
void read(T &x){
x=0;T flg=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}
//=========================================================================================================
// Define the global variables here.
bool membg=0;
int n;
bool memed=0;
//=========================================================================================================
// Code here.
void solve(){
read(n);
int x,y;
read(x,y);
set<int>s;
s.emplace(x+y),s.emplace(x-y);
for(int i=1,op;i<=n;i++){
read(op,x,y);
if(op==1)s.emplace(x+y),s.emplace(x-y);
else{
if(*s.rbegin()<=x){printf("%d\n", x-*s.rbegin());continue;}
auto it=s.lower_bound(x);int k=*it;
if(it!=s.begin())--it;
if(k<=y)printf("0\n");
else printf("%d\n",min(k-y,abs(x-*it)));
}
}
return;
}
//=========================================================================================================
int main(){
Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
int timbg=clock();
int T=1;
while(T--)solve();
int timed=clock();
Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
fflush(stdout);
return 0;
}
Submission Info
| Submission Time |
|
| Task |
B - Abs Abs Function |
| User |
EXODUS |
| Language |
C++ 20 (gcc 12.2) |
| Score |
500 |
| Code Size |
2004 Byte |
| Status |
AC |
| Exec Time |
124 ms |
| Memory |
20644 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
18 | #define Debug(...) 0
| ^
Main.cpp:71:9: note: in expansion of macro ‘Debug’
71 | Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
| ^~~~~
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
18 | #define Debug(...) 0
| ^
Main.cpp:76:9: note: in expansion of macro ‘Debug’
76 | Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
| ^~~~~
Main.cpp:72:13: warning: unused variable ‘timbg’ [-Wunused-variable]
72 | int timbg=clock();
| ^~~~~
Main.cpp:75:13: warning: unused variable ‘timed’ [-Wunused-variable]
75 | int timed=clock();
| ^~~~~
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 |
13 ms |
3660 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3504 KiB |
| 00_sample_03.txt |
AC |
1 ms |
3700 KiB |
| 01_rand1_01.txt |
AC |
92 ms |
13128 KiB |
| 01_rand1_02.txt |
AC |
90 ms |
13060 KiB |
| 01_rand1_03.txt |
AC |
89 ms |
13116 KiB |
| 01_rand1_04.txt |
AC |
94 ms |
13132 KiB |
| 01_rand1_05.txt |
AC |
92 ms |
13124 KiB |
| 01_rand1_06.txt |
AC |
87 ms |
13120 KiB |
| 01_rand1_07.txt |
AC |
87 ms |
13068 KiB |
| 01_rand1_08.txt |
AC |
93 ms |
13080 KiB |
| 01_rand1_09.txt |
AC |
92 ms |
12980 KiB |
| 01_rand1_10.txt |
AC |
91 ms |
13180 KiB |
| 01_rand1_11.txt |
AC |
94 ms |
13184 KiB |
| 01_rand1_12.txt |
AC |
91 ms |
12976 KiB |
| 01_rand1_13.txt |
AC |
90 ms |
13072 KiB |
| 01_rand1_14.txt |
AC |
88 ms |
13160 KiB |
| 02_rand2_01.txt |
AC |
70 ms |
13132 KiB |
| 02_rand2_02.txt |
AC |
72 ms |
12968 KiB |
| 02_rand2_03.txt |
AC |
72 ms |
13076 KiB |
| 02_rand2_04.txt |
AC |
64 ms |
13004 KiB |
| 02_rand2_05.txt |
AC |
69 ms |
13052 KiB |
| 02_rand2_06.txt |
AC |
63 ms |
13100 KiB |
| 02_rand2_07.txt |
AC |
84 ms |
13084 KiB |
| 02_rand2_08.txt |
AC |
84 ms |
13020 KiB |
| 02_rand2_09.txt |
AC |
88 ms |
13072 KiB |
| 02_rand2_10.txt |
AC |
76 ms |
20644 KiB |
| 02_rand2_11.txt |
AC |
76 ms |
20564 KiB |
| 02_rand2_12.txt |
AC |
80 ms |
20556 KiB |
| 02_rand2_13.txt |
AC |
110 ms |
20520 KiB |
| 02_rand2_14.txt |
AC |
120 ms |
20564 KiB |
| 02_rand2_15.txt |
AC |
124 ms |
20564 KiB |
| 03_test_01.txt |
AC |
1 ms |
3644 KiB |
| 03_test_02.txt |
AC |
88 ms |
12932 KiB |