답안 #159558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
159558 2019-10-23T08:29:30 Z geon040702 공주님의 정원 (KOI11_flower) C++14
18 / 18
47 ms 2168 KB
#include <bits/stdc++.h>
using namespace std;

pair<int, int> Data[100010];

int main(void)
{
    int N, i, j;
    scanf("%d", &N);

    for(i=0;i<N;i++) {
        int sm, sd, lm, ld;
        scanf("%d %d %d %d", &sm, &sd, &lm, &ld);
        Data[i].first = sm * 100 + sd;
        Data[i].second = lm * 100 + ld;
    }

    sort(Data, Data+N);
    int date = 301, flag, temp, ans;
    i=-1;
    flag = temp = ans = 0;

    while(date <= 1130 && i < N) {
        flag = 0;
        i++;
        for(j=i;j<N;j++) {
            if(Data[j].first > date) {
                break;
            }
            if(temp < Data[j].second) {
                temp = Data[j].second;
                flag = 1;
                i = j;
            }
        }
        if(flag) {
            date = temp;
            ans++;
        }
        else {
            printf("0\n");
            return 0;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Compilation message

flower.cpp: In function 'int main()':
flower.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
flower.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d %d", &sm, &sd, &lm, &ld);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 632 KB Output is correct
2 Correct 10 ms 632 KB Output is correct
3 Correct 14 ms 888 KB Output is correct
4 Correct 18 ms 1016 KB Output is correct
5 Correct 24 ms 1220 KB Output is correct
6 Correct 27 ms 1336 KB Output is correct
7 Correct 32 ms 1532 KB Output is correct
8 Correct 47 ms 2168 KB Output is correct
9 Correct 40 ms 2040 KB Output is correct
10 Correct 42 ms 2040 KB Output is correct