Submission #1085047

#TimeUsernameProblemLanguageResultExecution timeMemory
1085047SunbaeSchools (IZhO13_school)C++17
25 / 100
156 ms7200 KiB
#include <bits/stdc++.h> typedef long long ll; #define z exit(0) #define mp make_pair #define F first #define S second using namespace std; using pii = pair<int,int>; const int N = 3e5 + 5; pii a[N]; int v[N]; bool cmp1(int i, int j){ return mp(a[i].F - a[i].S, a[i].S) > mp(a[j].F - a[j].S, a[j].S); } bool cmp2(int i, int j){ return mp(a[i].S - a[i].F, a[i].F) > mp(a[j].S - a[j].F, a[j].F); } bool cmp11(int i, int j){ return a[i].S > a[j].S; } bool cmp22(int i, int j){ return a[i].F > a[j].F; } signed main(){ int n, m[2]; scanf("%d %d %d", &n, m, m+1); for(int i = 0, x, y; i<n; ++i){ scanf("%d %d", &x, &y); a[i] = mp(x, y); } for(int i = 0; i<n; ++i) v[i] = i; sort(v, v+n, cmp1); ll sum = 0; int idx = 0; for(int cnt = 0; cnt < m[0]; ++cnt, ++idx) sum += a[v[idx]].F; sort(v+idx, v+n, cmp11); for(int cnt = 0; cnt < m[1]; ++cnt, ++idx) sum += a[v[idx]].S; ll mx = sum; // sort(v, v+n, cmp2); sum = idx = 0; for(int cnt = 0; cnt < m[1]; ++cnt, ++idx) sum += a[v[idx]].S; sort(v+idx, v+n, cmp22); for(int cnt = 0; cnt < m[0]; ++cnt, ++idx) sum += a[v[idx]].F; mx = max(mx, sum); printf("%lld", mx); }

Compilation message (stderr)

school.cpp: In function 'int main()':
school.cpp:25:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  int n, m[2]; scanf("%d %d %d", &n, m, m+1);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d %d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...