답안 #24407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
24407 2017-06-07T08:27:11 Z Extazy 돌 무게 재기 (IZhO11_stones) C++14
0 / 100
676 ms 4664 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1<<17;

int n;
set < int, greater < int > > s[2];
set < int, greater < int > >::iterator it0,it1;
int cnt;

int main() {
    int i,x,y;

    scanf("%d", &n);
    for(i=1;i<=n;i++) {
        scanf("%d %d", &x, &y);
        s[y-1].insert(x);
        if(s[0].empty()) printf("<\n");
        else if(s[1].empty()) printf(">\n");
        else if(*s[0].begin()>*s[1].begin()) {
            if(s[0].size()<s[1].size()) {
                printf("?\n");
                continue;
            }
            cnt=0;
            for(it0=s[0].begin(),it1=s[1].begin();it0!=s[0].end() && it1!=s[1].end();it0++,it1++) {
                if(*it0>*it1) ++cnt;
                else break;
                if(cnt>1000) {
                    cnt=s[1].size();
                    break;
                }
            }
            if(cnt==(int)(s[1].size())) printf(">\n");
            else printf("?\n");
        }
        else {
            if(s[1].size()<s[0].size()) {
                printf("?\n");
                continue;
            }
            cnt=0;
            for(it0=s[0].begin(),it1=s[1].begin();it0!=s[0].end() && it1!=s[1].end();it0++,it1++) {
                if(*it0<*it1) ++cnt;
                else break;
                if(cnt>1000) {
                    cnt=s[0].size();
                    break;
                }
            }
            if(cnt==(int)(s[0].size())) printf("<\n");
            else printf("?\n");
        }
    }

    return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:15:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
stones.cpp:17:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &x, &y);
                               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Correct 0 ms 2024 KB Output is correct
4 Correct 0 ms 2024 KB Output is correct
5 Correct 0 ms 2024 KB Output is correct
6 Correct 0 ms 2024 KB Output is correct
7 Correct 0 ms 2024 KB Output is correct
8 Correct 0 ms 2156 KB Output is correct
9 Correct 0 ms 2156 KB Output is correct
10 Correct 19 ms 2420 KB Output is correct
11 Incorrect 676 ms 4664 KB Output isn't correct
12 Halted 0 ms 0 KB -