# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168105 | GioChkhaidze | Weighting stones (IZhO11_stones) | C++14 | 2 ms | 256 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
ll n,idx,type,A,B,G[N][3];
void Upd(int x,int type) {
while (x<=n) {
G[x][type]++;
x+=(x & -x);
}
}
ll Get(int x,int type) {
ll res=G[0][type];
while (x>0) {
res+=G[x][type];
x-=(x & -x);
}
return res;
}
main () {
scanf("%d",&n);
G[0][1]=G[0][2]=1;
for (int i=1; i<=n; i++) {
scanf("%d%d",&idx,&type);
if (type==1) {
A+=Get(idx-1,2);
B+=Get(n,2)-Get(idx,2);
}
else {
B+=Get(idx-1,1);
A+=Get(n,1)-Get(idx,1);
}
Upd(idx,type);
if (A>B) printf(">\n");
else
if (A<B) printf("<\n");
else printf("?\n");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |