# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108155 | 2024-11-03T04:36:48 Z | Tsagana | Weighting stones (IZhO11_stones) | C++14 | 2 ms | 336 KB |
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define lnl long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; pair<int, int> mn = {INT_MAX, 0}; pair<int, int> mx = {0, 0}; set<int> s; int id[100001]; int sd[3]; void add(int x, int i) { if (mn.F > x) mn = {x, i}; if (mx.F < x) mx = {x, i}; s.insert(-x); id[x] = i; sd[i]++; } char find() { if (sd[1] == 0) return '<'; if (sd[2] == 0) return '>'; if (mn.S == mx.S) return '?'; int l = mx.S; int k = 1; auto it = s.ub(-mx.S); while (it != s.end()) { int x = -*it; int i = id[x]; if (i == l) k++; else k--; if (k < 0) return '?'; } return (l == 1 ? '>' : '<'); } void solve () { int n; cin >> n; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; add(x, y); cout << find() << '\n'; } } signed main() { IOS #ifndef LOCAL freopen("stones.in", "r", stdin); freopen("stones.out", "w", stdout); #endif solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 336 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |