답안 #87026

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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

int x , a , n , x1 , x2;
set < int > v ;
set < int > :: iterator  vi ;
set < int > q ;
set < int > :: iterator  qi ;
int main()
{
     cin >> n ;
     for (int i = 0 ;i < n ;i ++ )
     {
         x1 = 0 ;
         x2 = 0 ;
         cin >> x >> a ;
         if (i == 0)
         {
            if (a == 1)
                cout << '>' << endl ;
            else
                cout << '<' << endl ;
            if (a == 1)
                v.insert (x) ;
            else
                q.insert (x) ;
         }
         else
         {

            if (a == 1)
                v.insert (x) ;
            else
                q.insert (x) ;
            if (v.size() == 0)
                cout << '<' << endl ;
            else
            if (q.size() == 0 )
                cout << '>' << endl ;
            else
            {
                qi = --q.end();

                for (vi = --v.end();  ; vi -- )
                {
                    if ( (*vi) > (*qi))
                        x1 ++ ;
                    else
                        x2 ++ ;
                    if (qi == q.begin() || vi == v.begin() || (x1 > 0 && x2 > 0) )
                        break;
                    qi -- ;
                }
                if (x1 > x2 && x2 == 0 && x1 == q.size() )
                    cout << '>' << endl ;
                else
                if (x1 < x2 && x1 == 0 && x2 == v.size() )
                    cout << '<' << endl;
                else
                    cout << '?' << endl ;
            }
        }
     }
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:64:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (x1 > x2 && x2 == 0 && x1 == q.size() )
                                           ~~~^~~~~~~~~~~
stones.cpp:67:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (x1 < x2 && x1 == 0 && x2 == v.size() )
                                           ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 276 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 3 ms 544 KB Output is correct
6 Correct 3 ms 748 KB Output is correct
7 Correct 6 ms 748 KB Output is correct
8 Correct 5 ms 748 KB Output is correct
9 Correct 5 ms 748 KB Output is correct
10 Correct 59 ms 1020 KB Output is correct
11 Execution timed out 1076 ms 2684 KB Time limit exceeded
12 Halted 0 ms 0 KB -