Submission #677596

#TimeUsernameProblemLanguageResultExecution timeMemory
677596MariabfBaloni (COCI15_baloni)C++17
0 / 100
2086 ms7292 KiB
#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)

baloni.cpp: In function 'int main()':
baloni.cpp:16:11: warning: unused variable 'b' [-Wunused-variable]
   16 |     }bool b=false;
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...