Submission #243505

#TimeUsernameProblemLanguageResultExecution timeMemory
243505abacaba학교 설립 (IZhO13_school)C++14
25 / 100
148 ms8568 KiB
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <typename T> inline T range(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}
 
inline void setin(string s) {
    freopen(s.c_str(), "r", stdin);
}
 
inline void setout(string s) {
    freopen(s.c_str(), "w", stdout);
}
 
template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

#define int long long

const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 3e5 + 15;
int n, x, y;
pii a[N];
int ans1, ans2;

inline int solve() {
    int ans = 0;
    sort(a + 1, a + 1 + n, [&](pii a, pii b) {
        return mp(a.f - a.se, a.f) > mp(b.f - b.se, b.f);
    });
    for(int i = 1; i <= x; ++i)
        ans += a[i].f;
    sort(a + x + 1, a + n + 1, [&](pii a, pii b) {
        return a.se > b.se;
    });
    for(int i = x + 1; i <= x + y; ++i)
        ans += a[i].se;
    return ans;
}

main() {
    ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    // setin("input.txt");
    cin >> n >> x >> y;
    for(int i = 1; i <= n; ++i)
        cin >> a[i].f >> a[i].se;
    int ans1 = solve();
    for(int i = 1; i <= n; ++i)
        swap(a[i].f, a[i].se);
    swap(x, y);
    int ans2 = solve();
    cout << max(ans1, ans2) << endl;
    return 0;
}

Compilation message (stderr)

school.cpp:85:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...