답안 #1112411

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1112411 2024-11-14T07:23:53 Z vjudge1 Baloni (COCI15_baloni) C++17
0 / 100
2000 ms 3664 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int a;
    cin >> a;
    
    vector<int> d(a);
    for (int i = 0; i < a; i++) {
        cin >> d[i];
    }

    int s = 0;

    while (!d.empty()) {
        int max_value = *max_element(d.begin(), d.end());
        auto it = find(d.begin(), d.end(), max_value);
        int maxi = distance(d.begin(), it);
        
        int ua = maxi;
        for (int i = maxi; i < d.size() - 1; i++) {
            if (d[i] - 1 == d[i + 1]) {
                d.erase(d.begin() + i);
                i--;
            } else {
                break;
            }
        }

        if (ua < d.size()) {
            d.erase(d.begin() + ua);
        }

        s++;
    }
    
    cout << s;

    return 0;
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:21:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int i = maxi; i < d.size() - 1; i++) {
      |                            ~~^~~~~~~~~~~~~~
baloni.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if (ua < d.size()) {
      |             ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Incorrect 2 ms 336 KB Output isn't correct
3 Incorrect 8 ms 336 KB Output isn't correct
4 Incorrect 12 ms 336 KB Output isn't correct
5 Execution timed out 2057 ms 3408 KB Time limit exceeded
6 Execution timed out 2045 ms 3664 KB Time limit exceeded
7 Execution timed out 2060 ms 3152 KB Time limit exceeded
8 Execution timed out 2070 ms 3152 KB Time limit exceeded
9 Execution timed out 2060 ms 3408 KB Time limit exceeded
10 Execution timed out 2055 ms 3408 KB Time limit exceeded