제출 #250681

#제출 시각아이디문제언어결과실행 시간메모리
250681kingfran1907Baloni (COCI15_baloni)C++14
100 / 100
1076 ms92428 KiB
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e6+10;

int n;
set< int > s[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        s[x].insert(i);
    }

    int sol = 0;
    for (int i = maxn - 10; i >= 0; i--) {
        while (!s[i].empty()) {
            int las = -1;
            int x = i;
            while (true) {
                auto iter = s[x].lower_bound(las);
                if (iter == s[x].end()) break;

                las = *iter + 1;
                s[x].erase(iter);
                x--;
            }
            sol++;
        }
    }
    printf("%d\n", sol);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

baloni.cpp: In function 'int main()':
baloni.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
baloni.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...