#include<bits/stdc++.h>
using namespace std;
int TC = 0;
void dbg_out() {cout << endl;}
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {cout << " " << H; dbg_out(T...);}
#define debug(...) {cout << "(" << #__VA_ARGS__ << "):"; dbg_out(__VA_ARGS__);}
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define add push_back
#define size(v) (int) v.size()
#define left node * 2, l, (l + r) / 2
#define right node * 2 + 1, (l + r) / 2 + 1, r
#define check() cout << "Why doesn't this stupid a** code work?" << endl;
#define inf (int) 1e18
vector<pair<int, int>> t(400005, {0, 0});
vector<int> p(400005, 0);
void update(int node, int l, int r, int L, int R, int val){
if(l > R || L > r) return;
if(L <= l && r <= R){
p[node] += val;
return;
}
t[node].first += p[node], t[node].second += p[node];
p[node * 2] += p[node];
p[node * 2 + 1] += p[node];
p[node] = 0;
update(left, L, R, val);
update(right, L, R, val);
t[node].first = min(t[node * 2].first + p[node * 2], t[node * 2 + 1].first + p[node * 2 + 1]);
t[node].second = max(t[node * 2].second + p[node * 2], t[node * 2 + 1].second + p[node * 2 + 1]);
}
void solve(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
int r, s;
cin >> r >> s;
int k = (s == 1 ? 1 : -1);
update(1, 1, n, 1, r, k);
if((t[1].first + p[1]) * (t[1].second + p[1]) < 0){
cout << "?\n";
}
else if((t[1].first + p[1]) > 0 || (t[1].second + p[1]) > 0){
cout << ">\n";
}
else{
cout << "<\n";
}
}
}
signed main(){
int q = 1;
//cin >> q;
while(++TC <= q){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
9816 KB |
Output is correct |
2 |
Correct |
3 ms |
9820 KB |
Output is correct |
3 |
Correct |
3 ms |
9816 KB |
Output is correct |
4 |
Correct |
3 ms |
9848 KB |
Output is correct |
5 |
Correct |
3 ms |
9816 KB |
Output is correct |
6 |
Correct |
4 ms |
9816 KB |
Output is correct |
7 |
Correct |
4 ms |
9816 KB |
Output is correct |
8 |
Correct |
5 ms |
9816 KB |
Output is correct |
9 |
Correct |
4 ms |
9816 KB |
Output is correct |
10 |
Correct |
18 ms |
9816 KB |
Output is correct |
11 |
Correct |
106 ms |
10588 KB |
Output is correct |
12 |
Correct |
155 ms |
10576 KB |
Output is correct |
13 |
Correct |
166 ms |
10768 KB |
Output is correct |
14 |
Correct |
186 ms |
10576 KB |
Output is correct |
15 |
Correct |
175 ms |
10576 KB |
Output is correct |
16 |
Correct |
164 ms |
10564 KB |
Output is correct |
17 |
Correct |
163 ms |
10576 KB |
Output is correct |
18 |
Correct |
166 ms |
10576 KB |
Output is correct |
19 |
Correct |
165 ms |
10576 KB |
Output is correct |
20 |
Correct |
183 ms |
10668 KB |
Output is correct |
21 |
Correct |
165 ms |
10768 KB |
Output is correct |
22 |
Correct |
173 ms |
10760 KB |
Output is correct |
23 |
Correct |
163 ms |
10576 KB |
Output is correct |
24 |
Correct |
167 ms |
10816 KB |
Output is correct |
25 |
Correct |
166 ms |
10576 KB |
Output is correct |