#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int nmax = 5e5 + 1;
struct node{
int sum, mn, mx;
node(){
sum = 0;
mx = -1e9;
mn = 1e9;
}
node(int val){
sum = val;
mx = val;
mn = val;
}
}t[4 * nmax];
node merg(node a, node b){
node c;
c.sum = a.sum + b.sum;
c.mn = min(a.mn + b.sum, b.mn);
c.mx = max(a.mx + b.sum, b.mx);
return c;
}
void update(int v, int l, int r, int pos, int val){
if(l > pos || r < pos) return;
if(l == r){
t[v] = {val};
return;
}
int m = (l + r) / 2;
update(2 * v, l, m, pos, val);
update(2 * v + 1, m + 1, r, pos, val);
t[v] = merg(t[2 * v], t[2 * v + 1]);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
pii mx = {0, 0};
int n; cin >> n;
for(int i = 1; i <= n; i++){
int x, y; cin >> x >> y;
if(y == 1)
update(1, 1, n, x, 1);
else update(1, 1, n, x, -1);
if(mx.f < x)
mx = {x, y};
if(mx.s == 1){
if(t[1].mn >= 0) cout << '>';
else cout << '?';
}
else{
//cout << t[1].mx << "\n";
if(t[1].mx <= 0) cout << '<';
else cout << '?';
}
cout << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23748 KB |
Output is correct |
2 |
Correct |
14 ms |
23776 KB |
Output is correct |
3 |
Correct |
12 ms |
23764 KB |
Output is correct |
4 |
Correct |
12 ms |
23764 KB |
Output is correct |
5 |
Correct |
11 ms |
23764 KB |
Output is correct |
6 |
Correct |
11 ms |
23760 KB |
Output is correct |
7 |
Correct |
11 ms |
23808 KB |
Output is correct |
8 |
Correct |
13 ms |
23744 KB |
Output is correct |
9 |
Correct |
11 ms |
23812 KB |
Output is correct |
10 |
Correct |
16 ms |
23760 KB |
Output is correct |
11 |
Correct |
34 ms |
24268 KB |
Output is correct |
12 |
Correct |
65 ms |
24636 KB |
Output is correct |
13 |
Correct |
53 ms |
24648 KB |
Output is correct |
14 |
Correct |
53 ms |
24708 KB |
Output is correct |
15 |
Correct |
50 ms |
24744 KB |
Output is correct |
16 |
Correct |
47 ms |
24732 KB |
Output is correct |
17 |
Correct |
49 ms |
24652 KB |
Output is correct |
18 |
Correct |
48 ms |
24736 KB |
Output is correct |
19 |
Correct |
48 ms |
24708 KB |
Output is correct |
20 |
Correct |
48 ms |
24740 KB |
Output is correct |
21 |
Correct |
50 ms |
24740 KB |
Output is correct |
22 |
Correct |
80 ms |
24720 KB |
Output is correct |
23 |
Correct |
46 ms |
24692 KB |
Output is correct |
24 |
Correct |
47 ms |
24652 KB |
Output is correct |
25 |
Correct |
46 ms |
24684 KB |
Output is correct |