Submission #88949

#TimeUsernameProblemLanguageResultExecution timeMemory
88949LkvatashidzeSchools (IZhO13_school)C++17
0 / 100
5 ms844 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; pair < ll, ll > a[300005]; pair < ll, ll > b[300005]; ll used[300005]; ll n, m, s; ll ans, ans0; int main() { freopen ("school.in", "r", stdin); freopen ("school.out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> s; for (ll k=1; k<=n; k++) { ll x, y; cin >> x >> y; a[k].first=x; a[k].second=k; b[k].first=y; b[k].second=k; } sort (a+1,a+1+n); sort (b+1,b+1+n); for (ll k=n; k>=n-m+1; k--) { ans+=a[k].first; used[a[k].second]=true; } reverse(b+1,b+1+n); ll i=1; ll j=1; while (i<=s && j<=n) { if (used[b[j].second]) { j++; continue; } ans+=b[j].first; used[b[j].second]=true; j++; i++; } for (ll k=1; k<=n; k++) used[k]=false; sort (a+1,a+1+n); sort (b+1,b+1+n); for (ll k=n; k>=n-s+1; k--) { ans0+=b[k].first; used[b[k].second]=true; } reverse(a+1,a+1+n); i=1; j=1; while (i<=m && j<=n) { if (used[a[j].second]) { j++; continue; } ans0+=a[j].first; used[b[j].second]=true; j++; i++; } cout << max(ans,ans0); return 0; }

Compilation message (stderr)

school.cpp: In function 'int main()':
school.cpp:13:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen ("school.in", "r", stdin);
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:14:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen ("school.out", "w", stdout);
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...