Submission #1112460

# Submission time Handle Problem Language Result Execution time Memory
1112460 2024-11-14T08:23:42 Z vjudge1 Baloni (COCI15_baloni) C++11
40 / 100
2000 ms 3664 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")




int main()
{
    int n,count = 0;

    int max=0,index=0;

    std::cin >> n;

    std::vector<int> arr(n,0);

    for(int &i:arr)
    std::cin >> i;



    
    std::queue<int> q;

    while(arr.size()>0)
    {
        int balon=arr[0];
        count++;
        for(int i=0;i<arr.size();i++)
        {
            if(arr[i]==balon)
            {
                q.push(i);
                balon--;

            }
            if(balon==0)
            break;

        }
        int katsayi=0;
        while(!q.empty())
        {
            
            int x = q.front();
            q.pop();
            arr.erase(arr.begin()+x-katsayi);
            katsayi++;
        }
        
    }

    

    std::cout << count;
    
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int i=0;i<arr.size();i++)
      |                     ~^~~~~~~~~~~
baloni.cpp:11:9: warning: unused variable 'max' [-Wunused-variable]
   11 |     int max=0,index=0;
      |         ^~~
baloni.cpp:11:15: warning: unused variable 'index' [-Wunused-variable]
   11 |     int max=0,index=0;
      |               ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 3 ms 508 KB Output is correct
4 Correct 5 ms 452 KB Output is correct
5 Execution timed out 2070 ms 3408 KB Time limit exceeded
6 Execution timed out 2079 ms 3664 KB Time limit exceeded
7 Execution timed out 2073 ms 3152 KB Time limit exceeded
8 Execution timed out 2045 ms 3152 KB Time limit exceeded
9 Execution timed out 2044 ms 3408 KB Time limit exceeded
10 Execution timed out 2045 ms 3408 KB Time limit exceeded