답안 #568673

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
568673 2022-05-26T03:25:32 Z Garguy22 Baloni (COCI15_baloni) C++17
40 / 100
2000 ms 7260 KB
#include <iostream>
using namespace std;

const int MAXN = 1e6 + 7;

int a[MAXN];

int main() {
    
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int cur, ans = 0;
    for(int i = 1; i <= n; i++)
    {
        cur = a[i];
        if(a[i] == -1)
            continue;
        ans++;
        for(int j = i+1; j <= n ; j++)
        {
            if(a[j] == -1)
                continue;
            if(cur-1 == a[j])
            {
                a[j] = -1;
                cur--;
            }
        }
        a[i] = -1;
    }
    cout << ans << endl;
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 13 ms 340 KB Output is correct
4 Correct 23 ms 336 KB Output is correct
5 Execution timed out 2095 ms 6924 KB Time limit exceeded
6 Execution timed out 2066 ms 7260 KB Time limit exceeded
7 Execution timed out 2086 ms 5888 KB Time limit exceeded
8 Execution timed out 2072 ms 5844 KB Time limit exceeded
9 Execution timed out 2085 ms 6464 KB Time limit exceeded
10 Execution timed out 2079 ms 6560 KB Time limit exceeded