답안 #48393

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48393 2018-05-12T17:05:53 Z ernestvw 돌 무게 재기 (IZhO11_stones) C++11
0 / 100
1000 ms 1584 KB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int nbStones;
int suffix[100001];

int main(){
    scanf("%d", &nbStones);
    for(int i = 1; i <= nbStones; i++) suffix[i] = 0;
    int maxi = 0;
    int mini = 0;
    for(int q = 1; q <= nbStones; q++){
        int indice, side;
        scanf("%d%d", &indice, &side);
        for(int i = 1; i <= nbStones; i++)
            if(i <= indice)
                suffix[i]+=(side==1?1:-1);
        maxi=0,mini=0;
        for(int i=1;i<=nbStones;i++)
            maxi=max(maxi, suffix[i]), mini=min(mini, suffix[i]);
        if(maxi>0 and mini<0)printf("?");
        else if(maxi==0 and mini==0)printf("?");
        else if(maxi>0)printf(">");
        else if(mini<0)printf("<");
        printf("\n");
    }
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &nbStones);
     ~~~~~^~~~~~~~~~~~~~~~~
stones.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &indice, &side);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 3 ms 680 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 5 ms 724 KB Output is correct
8 Correct 6 ms 728 KB Output is correct
9 Correct 4 ms 756 KB Output is correct
10 Correct 150 ms 1012 KB Output is correct
11 Execution timed out 1088 ms 1584 KB Time limit exceeded
12 Halted 0 ms 0 KB -