답안 #1112506

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

int main() {
    long long int s = 0, a;
    cin >> a;
    
    vector<int> d(a);
    
    for (long long int i = 0; i < a; i++) {
        cin >> d[i];
    }
    
    while (true) {
        long long int maxi = -1, max = INT_MIN;
        
        for (long long int i = 0; i < d.size(); i++) {
            if (d[i] > max) {
                max = d[i];
                maxi = i;
            }
        }
        
        if (maxi == -1) {
            break;
        }
        
        long long int ua = -1;
        
        for (long long int i = maxi; i < d.size() - 1; i++) {
            if (d[i] - 1 == d[i + 1]) {
                d.erase(d.begin() + i);
                ua = i;
                i--;
            } else {
                break;
            }
        }
        
        if (ua != -1 && ua < d.size()) {
            d.erase(d.begin() + ua);
        }
        
        s++;
    }
    
    cout << s;

    return 0;
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:17:37: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (long long int i = 0; i < d.size(); i++) {
      |                                   ~~^~~~~~~~~~
baloni.cpp:30:40: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (long long int i = maxi; i < d.size() - 1; i++) {
      |                                      ~~^~~~~~~~~~~~~~
baloni.cpp:40:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if (ua != -1 && ua < d.size()) {
      |                         ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2063 ms 336 KB Time limit exceeded
2 Execution timed out 2056 ms 336 KB Time limit exceeded
3 Execution timed out 2062 ms 336 KB Time limit exceeded
4 Execution timed out 2055 ms 336 KB Time limit exceeded
5 Execution timed out 2067 ms 3408 KB Time limit exceeded
6 Execution timed out 2037 ms 3664 KB Time limit exceeded
7 Execution timed out 2079 ms 3152 KB Time limit exceeded
8 Execution timed out 2058 ms 3152 KB Time limit exceeded
9 Execution timed out 2061 ms 3408 KB Time limit exceeded
10 Execution timed out 2069 ms 3408 KB Time limit exceeded