Submission #677596

# Submission time Handle Problem Language Result Execution time Memory
677596 2023-01-03T21:44:56 Z Mariabf Baloni (COCI15_baloni) C++17
0 / 100
2000 ms 7292 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    map<int, pair<int, int>>m;
    vector<int>nums(n);
    for(int i=0; i<n; i++){
        cin>>nums[i];
        if(m.find(-nums[i])!=m.end()){
            m[-nums[i]].first++;
        }
        else{
            m[-nums[i]]=make_pair(1, i);
        }
    }bool b=false;
    int arrows=0;
    auto it=m.begin();
    for(pair<int, pair<int, int>>x:m){
        if(x.second.first){
            x.second.first--;
            arrows++;
            int h=-x.first-1;
            for(int i=x.second.second+1; i<n; i++){
                if(m[-nums[i]].first&&nums[i]==h){
                    h--;
                    m[-nums[i]].first--;
                }
            }
        }it++;
    }cout<<arrows;
}

Compilation message

baloni.cpp: In function 'int main()':
baloni.cpp:16:11: warning: unused variable 'b' [-Wunused-variable]
   16 |     }bool b=false;
      |           ^
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 340 KB Output isn't correct
2 Incorrect 45 ms 344 KB Output isn't correct
3 Incorrect 132 ms 368 KB Output isn't correct
4 Incorrect 185 ms 376 KB Output isn't correct
5 Execution timed out 2086 ms 7120 KB Time limit exceeded
6 Execution timed out 2069 ms 7292 KB Time limit exceeded
7 Execution timed out 2085 ms 6020 KB Time limit exceeded
8 Execution timed out 2060 ms 6116 KB Time limit exceeded
9 Execution timed out 2078 ms 6476 KB Time limit exceeded
10 Execution timed out 2074 ms 6524 KB Time limit exceeded