Submission #167900

#TimeUsernameProblemLanguageResultExecution timeMemory
167900GioChkhaidzeSchools (IZhO13_school)C++14
15 / 100
421 ms32456 KiB
#include <bits/stdc++.h> #define ll long long #define F first #define S second using namespace std; const int N=3e5+5; ll n,m,s,a[N],b[N],f[N],ans; vector < pair < ll , pair < ll , ll > > > v; main () { cin>>n>>m>>s; for (int i=1; i<=n; i++) { cin>>a[i]>>b[i]; v.push_back({a[i],{i,0}}); v.push_back({b[i],{i,1}}); } sort(v.begin(),v.end()); reverse(v.begin(),v.end()); for (int i=0; i<v.size(); i++) { ll type=v[i].S.S,idx=v[i].S.F; if (f[idx]) continue; if (!type) { if (m) { ans+=a[idx]; m--; f[idx]=1; } } else { if (s) { ans+=b[idx]; s--; f[idx]=1; } } } cout<<ans<<endl; }

Compilation message (stderr)

school.cpp:9:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
school.cpp: In function 'int main()':
school.cpp:21:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<v.size(); i++) {
                ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...