Submission #725498

# Submission time Handle Problem Language Result Execution time Memory
725498 2023-04-17T14:26:33 Z vjudge1 Schools (IZhO13_school) C++17
5 / 100
105 ms 5196 KB
#include <bits/stdc++.h>
#define B begin()
#define rB rbegin()
#define E end()
#define rE rend()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define sts stable_sort
using namespace std;

const int MAXN = 1e6 + 4;
const int MOD = 1e9 + 7;
bool comp[MAXN];
ll res = 0;

//void f(vector<pair<int, int> > v, vector<pair<int, int> > b, int m, int s, int n){
//    for(int i = 0 ; i < n; i++){
//        if(comp[i])continue;
//        if(m == 0){
//            for(int j = i; j < n && s > 0; j++){
//                if(comp[j])continue;
//                res += b[j];
//                s--;
//            }
//            return;
//        }else if(s == 0){
//            for(int j = i; j < n && m > 0; j++){
//                if(comp[j])continue;
//                res += v[j];
//                m--;
//            }
//            return;
//        }
//        if(v[i].S == b[i].S){
//            if(v[i].F >= b[i].F){
//                res += v[i].F;
//                m--;
//                comp[v[i].S] = 1;
//                for(int j = i + 1; j < n; j++){
//                    if(comp[j])continue;
//                    res += b[j].F;
//                    comp[b[j].S] = 1;
//                    break;
//                }
//            }else{
//                res += b[i].F;
//                s--;
//                comp[b[i].S] = 1;
//                for(int j = i + 1; j < n; j++){
//                    if(comp[j])continue;
//                    res += v[j].F;
//                    comp[v[j].S] = 1;
//                    break;
//                }
//            }
//        }else{
//            if(v[i].S >= b[i].F){
//                res +=
//                comp[v[i].S] = 1;
//                m--;
//            }
//        }
//    }
//}

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

    int n, M, S; cin >> n >> M >> S;
    vector<pair<int, int> > v(n);
    vector<pair<int, int> > b(n);

    for(int i = 0; i < n; i++){
        cin >> v[i].F; v[i].S = i;
        cin >> b[i].F; b[i].S = i;
    }
    sort(v.rB, v.rE);
    sort(b.rB, b.rE);

    for(int i = 0; i < n; i++){
        if(M == 0)break;
        if(comp[v[i].S])continue;
        res += v[i].F;
        comp[v[i].S] = 1;
        M--;
    }

    for(int i = 0; i < n; i++){
        if(S == 0)break;
        if(comp[b[i].S])continue;
        res += b[i].F;
        comp[b[i].S] = 1;
        S--;
    }
    cout << res << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 2 ms 340 KB Output isn't correct
8 Incorrect 2 ms 340 KB Output isn't correct
9 Incorrect 2 ms 340 KB Output isn't correct
10 Incorrect 2 ms 340 KB Output isn't correct
11 Incorrect 2 ms 340 KB Output isn't correct
12 Incorrect 2 ms 340 KB Output isn't correct
13 Incorrect 13 ms 904 KB Output isn't correct
14 Incorrect 26 ms 1556 KB Output isn't correct
15 Incorrect 53 ms 2940 KB Output isn't correct
16 Incorrect 63 ms 3256 KB Output isn't correct
17 Incorrect 77 ms 3868 KB Output isn't correct
18 Incorrect 82 ms 4212 KB Output isn't correct
19 Incorrect 95 ms 4512 KB Output isn't correct
20 Incorrect 105 ms 5196 KB Output isn't correct