#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int pus[N];
pii der[N];
void push(int v,int l,int r){
der[v].fr += pus[v];
der[v].sc += pus[v];
if (l != r){
pus[v<<1]+=pus[v];
pus[(v<<1)+1]+=pus[v];
}
pus[v]=0;
}
void update(int v,int l,int r,int ql,int qr,int x){
push(v,l,r);
if (ql > r || l > qr)ret ;
if (ql <= l && r <= qr){
pus[v]+=x;
push(v,l,r);
ret ;
}
int m = (l+r)>>1;
update(v<<1,l,m,ql,qr,x);
update((v<<1)+1,m+1,r,ql,qr,x);
der[v].fr = min(der[v<<1].fr,der[(v<<1)+1].fr);
der[v].sc = max(der[v<<1].sc,der[(v<<1)+1].sc);
}
main(){
int n,i;
scan1(n)
i=n;
while (i--){
int a,b;
scan2(a,b)
if (b == 1){
update(1,1,n,1,a,-1);
}
else {
update(1,1,n,1,a,1);
}
if (der[1].fr >= 0){
cout <<"<\n";
}
else if (der[1].sc <= 0){
cout <<">\n";
}
else cout <<"?\n";
}
}
Compilation message
stones.cpp:48:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
48 | main(){
| ^
stones.cpp: In function 'int main()':
stones.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
11 | #define scan1(a) scanf("%lld",&a);
| ~~~~~^~~~~~~~~~~
stones.cpp:50:5: note: in expansion of macro 'scan1'
50 | scan1(n)
| ^~~~~
stones.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
stones.cpp:54:9: note: in expansion of macro 'scan2'
54 | scan2(a,b)
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
236 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
6 ms |
1132 KB |
Output is correct |
11 |
Correct |
43 ms |
3820 KB |
Output is correct |
12 |
Correct |
76 ms |
6892 KB |
Output is correct |
13 |
Correct |
66 ms |
6892 KB |
Output is correct |
14 |
Correct |
67 ms |
6892 KB |
Output is correct |
15 |
Correct |
66 ms |
6912 KB |
Output is correct |
16 |
Correct |
76 ms |
6892 KB |
Output is correct |
17 |
Correct |
69 ms |
7020 KB |
Output is correct |
18 |
Correct |
67 ms |
6892 KB |
Output is correct |
19 |
Correct |
65 ms |
6892 KB |
Output is correct |
20 |
Correct |
65 ms |
6912 KB |
Output is correct |
21 |
Correct |
70 ms |
7020 KB |
Output is correct |
22 |
Correct |
72 ms |
6892 KB |
Output is correct |
23 |
Correct |
68 ms |
6892 KB |
Output is correct |
24 |
Correct |
66 ms |
6892 KB |
Output is correct |
25 |
Correct |
65 ms |
7020 KB |
Output is correct |