#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ALL(v) v.begin(),v.end()
#define MASK(k) (1LL << (k))
#define BIT(x, i) (((x) >> (i)) & 1)
#define oo (ll)1e18
#define INF (ll)1e9
#define MOD (ll)(998244353)
using namespace std;
template<class T1, class T2>
bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2>
bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2>
void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;}
template<class T1, class T2>
void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;}
template<class T>
void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}
struct seg{
vector<int> ma, mi, laz;
int n;
seg(int _n = 0){
n = _n;
ma.resize(n * 4 + 3, 0);
mi.resize(n * 4 + 3, 0);
laz.resize(n * 4 + 3, 0);
}
void push(int i){
ma[i * 2] += laz[i];
ma[i * 2 + 1] += laz[i];
mi[i * 2] += laz[i];
mi[i * 2 + 1] += laz[i];
laz[i * 2] += laz[i];
laz[i * 2 + 1] += laz[i];
laz[i] = 0;
}
void upd(int i, int l, int r, int u, int v, int c){
if(r < u || v < l) return;
if(u <= l && r <= v){
ma[i] += c;
mi[i] += c;
laz[i] += c;
return;
}
push(i);
int m = (l + r) >> 1;
upd(i * 2, l, m, u, v, c);
upd(i * 2 + 1, m + 1, r, u, v, c);
mi[i] = min(mi[i * 2], mi[i * 2 + 1]);
ma[i] = max(ma[i * 2], ma[i * 2 + 1]);
}
void upd(int u, int v, int c){
upd(1, 1, n, u, v, c);
}
};
void solve(){
int n;
cin >> n;
seg it(n);
while(n--){
int a, b;
cin >> a >> b;
if(b == 1){
it.upd(1, a, -1);
}
else{
it.upd(1, a, 1);
}
int ma = it.ma[1], mi = it.mi[1];
if(ma <= 0) cout << ">\n";
else if(mi >= 0) cout << "<\n";
else cout << "?\n";
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("numtable.inp","r",stdin);
// freopen("numtable.out","w",stdout);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
860 KB |
Output is correct |
11 |
Correct |
20 ms |
3160 KB |
Output is correct |
12 |
Correct |
33 ms |
4700 KB |
Output is correct |
13 |
Correct |
37 ms |
5260 KB |
Output is correct |
14 |
Correct |
31 ms |
5212 KB |
Output is correct |
15 |
Correct |
32 ms |
5344 KB |
Output is correct |
16 |
Correct |
33 ms |
5212 KB |
Output is correct |
17 |
Correct |
42 ms |
5172 KB |
Output is correct |
18 |
Correct |
35 ms |
5944 KB |
Output is correct |
19 |
Correct |
33 ms |
5980 KB |
Output is correct |
20 |
Correct |
32 ms |
6076 KB |
Output is correct |
21 |
Correct |
34 ms |
5968 KB |
Output is correct |
22 |
Correct |
33 ms |
5904 KB |
Output is correct |
23 |
Correct |
31 ms |
5980 KB |
Output is correct |
24 |
Correct |
35 ms |
5944 KB |
Output is correct |
25 |
Correct |
36 ms |
5976 KB |
Output is correct |