답안 #87034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87034 2018-11-29T09:09:14 Z mirbek01 돌 무게 재기 (IZhO11_stones) C++17
0 / 100
1000 ms 1328 KB
# include <bits/stdc++.h>

using namespace std;

int q;
set <int> s1, s2;

int main(){
      scanf("%d", &q);

      while(q --){
            int val, type;
            cin >> val >> type;
            if(type == 1){
                  s1.insert(val);
            } else {
                  s2.insert(val);
            }
            vector <int> v1, v2;
            for(auto i : s1)
                  v1.push_back(i);
            for(auto i : s2)
                  v2.push_back(i);
            int pos = 0;
            bool ok = 1;
            for(int i = 0; i < v1.size(); i ++){
                  while(pos < v2.size() && v2[pos] < v1[i])
                        pos ++;
                  if(pos >= v2.size()){
                        ok = 0;
                        break;
                  }
                  pos ++;
            }
            if(ok){
                  puts("<");
                  continue;
            }
            pos = 0;
            ok = 1;
            for(int i = 0; i < v2.size(); i ++){
                  while(pos < v1.size() && v1[pos] < v2[i])
                        pos ++;
                  if(pos >= v1.size()){
                        ok = 0;
                        break;
                  }
                  pos ++;
            }
            if(ok || v1.empty()){
                  puts(">");
            } else {
                  puts("?");
            }
      }
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:26:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i = 0; i < v1.size(); i ++){
                            ~~^~~~~~~~~~~
stones.cpp:27:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   while(pos < v2.size() && v2[pos] < v1[i])
                         ~~~~^~~~~~~~~~~
stones.cpp:29:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   if(pos >= v2.size()){
                      ~~~~^~~~~~~~~~~~
stones.cpp:41:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i = 0; i < v2.size(); i ++){
                            ~~^~~~~~~~~~~
stones.cpp:42:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   while(pos < v1.size() && v1[pos] < v2[i])
                         ~~~~^~~~~~~~~~~
stones.cpp:44:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   if(pos >= v1.size()){
                      ~~~~^~~~~~~~~~~~
stones.cpp:9:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", &q);
       ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 3 ms 392 KB Output is correct
4 Correct 2 ms 520 KB Output is correct
5 Correct 4 ms 520 KB Output is correct
6 Correct 6 ms 520 KB Output is correct
7 Correct 10 ms 520 KB Output is correct
8 Correct 16 ms 672 KB Output is correct
9 Correct 12 ms 672 KB Output is correct
10 Correct 992 ms 1212 KB Output is correct
11 Execution timed out 1076 ms 1328 KB Time limit exceeded
12 Halted 0 ms 0 KB -