제출 #81164

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

using namespace std;

const int N = 1e6 + 5;

int n, a[N], ans = 0;
set <int> pos[N];
bool used[N];

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), pos[a[i]].insert(i);
    for (int i = 1; i <= n; i++) {
        if (used[i]) continue;
        ans++;
        int pt = a[i], lst = i;
        while (pt >= 1) {
            auto it = pos[pt].lower_bound(lst);
            if (it == pos[pt].end()) break;
            lst = *it;
            pos[pt].erase(it);
            used[lst] = true;
            pt--;
        }
    }

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

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

baloni.cpp: In function 'int main()':
baloni.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
baloni.cpp:13:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; i++) scanf("%d", &a[i]), pos[a[i]].insert(i);
                                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…