Submission #26023

#TimeUsernameProblemLanguageResultExecution timeMemory
26023iletavcioskiUnija (COCI17_unija)C++14
100 / 100
426 ms26796 KiB
#include<iostream> #include<vector> #include<algorithm> #include<cmath> #include<iomanip> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); int n; cin>>n; vector<pair<ll,ll> >v; for(int i=0;i<n;i++) { ll a,b; cin>>a>>b; b/=2; v.push_back(make_pair(a,b)); } sort(v.begin(),v.end()); reverse(v.begin(),v.end()); int i=0; ll maxi=0; ll prethoden=0; ll brojac=0; while(i<n) { if(v[i].second>maxi) { brojac+=((v[i].second-maxi)*v[i].first); maxi=v[i].second; } i++; } brojac*=2; cout<<brojac<<endl; return 0; }

Compilation message (stderr)

unija.cpp: In function 'int main()':
unija.cpp:25:8: warning: unused variable 'prethoden' [-Wunused-variable]
     ll prethoden=0;
        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...