Submission #895569

#TimeUsernameProblemLanguageResultExecution timeMemory
895569preskoSchools (IZhO13_school)C++14
15 / 100
96 ms10164 KiB
#include<iostream> #include<bits/stdc++.h> #define MAXN 300010 using namespace std; pair<int,int> city[MAXN]; vector<pair<int,int>> order; vector<pair<int,int>> var; bool used1[MAXN]; bool used2[MAXN]; int main() { int n,m,s; ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m>>s; for(int i=1;i<=n;i++) { cin>>city[i].first>>city[i].second; order.push_back({city[i].first,i}); var.push_back({city[i].second,i}); } sort(order.begin(),order.end(),greater<pair<int,int>>()); sort(var.begin(),var.end(),greater<pair<int,int>>()); long long ans1=0,ans2=0; for(int i=0;i<m;i++) { int mus=order[i].first; int ind=order[i].second; ans1+=mus; used1[ind]=1; } int cntr=s; for(int i=0;i<var.size();i++) { int sp=var[i].first; int ind=var[i].second; if(used1[ind]==0) { ans1+=sp; cntr--; } if(cntr==0)break; } for(int i=0;i<s;i++) { int sp=var[i].first; int ind=var[i].second; ans2+=sp; used2[ind]=1; } cntr=m; for(int i=0;i<order.size();i++) { int mus=order[i].first; int ind=order[i].second; if(used2[ind]==0) { ans2+=mus; cntr--; } if(cntr==0)break; } if(ans1<=ans2)cout<<ans2<<"\n"; else cout<<ans1<<"\n"; }

Compilation message (stderr)

school.cpp: In function 'int main()':
school.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<var.size();i++)
      |                 ~^~~~~~~~~~~
school.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i=0;i<order.size();i++)
      |                 ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...