# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
677596 | Mariabf | Baloni (COCI15_baloni) | C++17 | 2086 ms | 7292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |