# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
87039 | abil | 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.
/**
Solution by Abil
**/
#include <bits/stdc++.h>
using namespace std;
vector<int > v1,v2;
vector<int > :: iterator it;
int fun(int qw){
int f = 0;
if(v1.size() == v2.size()){
bool bl = true;
for(int i = 0;i < v1.size(); i++){
if(v1[i] < v2[i]){
bl = false;
break;
}
}
if(bl){
f = 1;
}
bl = true;
for(int i = 0;i < v1.size(); i++){
if(v1[i] > v2[i]){
bl = false;
break;
}
}
if(bl){
f = 2;
}
}
else{
int cnt1 = 0,cnt2 = 0,in = 0;
for(int i = 0;i < v1.size(); i++){
if(in < v2.size() && v1[i] > v2[in] ){
cnt1++;
in++;
}
}
in = 0;
for(int i = 0;i < v2.size(); i++){
if(in < v1.size() && v1[in] < v2[i]){
cnt2++;
in++;
}
}
//cout << cnt1 << " " << cnt2 << endl;
if(cnt1 > cnt2 ||( cnt1 == cnt2 && v1.size() > v2.size())){
f = 1;
}
if(cnt2 > cnt1 ||( cnt1 == cnt2 && v1.size() < v2.size())){
f = 2;
}
}
return f;
}
int main()
{
int n,ans1 = 0,ans2 = 0;
cin >> n;
int ves,dir;
while(n--){
cin >> ves >> dir;
if(dir == 1){
if(v1.size() > 0){
it = lower_bound(v1.begin(),v1.end(),ves);
v1.insert(it,ves);
}
else{
v1.push_back(ves);
}
}
else{
if(v2.size() > 0){
it = lower_bound(v2.begin(),v2.end(),ves);
v2.insert(it,ves);
}
else{
v2.push_back(ves);
}
}
int f = fun(1);
if(f == 0){
cout << "?" << endl;
}
else
if(f == 1){
cout << ">" << endl;
}
else{
cout << "<" << endl;
}
}
}
/*
7
1 1
2 2
3 1
4 2
5 1
6 2
7 1
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |