Submission #1149008

#TimeUsernameProblemLanguageResultExecution timeMemory
1149008uasdfaeSchools (IZhO13_school)C++17
0 / 100
1 ms328 KiB
#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef pair<ll, ll> ii;
#define fi first
#define se second
#define mask(i) (1LL << (i))


const int N = 1e3 + 5;
const ll inf = 1e17;

int k, n, m;
ii a[N];

bool cmp(ii a, ii b) { return a.fi - a.se > b.fi - b.se; }
bool cmp2(ii a, ii b) { return a.se > b.se; }


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    freopen("school.in", "r", stdin);
    freopen("school.out", "w", stdout);

    cin >> k >> n >> m;
    for (int i = 1; i <= k; i++) cin >> a[i].fi >> a[i].se;

    sort(a + 1, a + k + 1, cmp);
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        res += a[i].fi;
        a[i].se = -1;
    }

    sort(a + 1, a + k + 1, cmp2);
    for (int i = 1; i <= m; i++) res += a[i].se;
    cout << res;

}

Compilation message (stderr)

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