Submission #788754

# Submission time Handle Problem Language Result Execution time Memory
788754 2023-07-20T14:47:00 Z stefanneagu Self Study (JOI22_ho_t2) C++17
62 / 100
1000 ms 27392 KB
#include <iostream>
#include <set>
#define int long long

using namespace std;

const int nmax = 3e5 + 7;

int v[nmax], b[nmax], cnt[nmax];

struct pairing {
    int first, second;
    const bool operator < (pairing a) const {
        if(first != a.first) {
            return first < a.first;
        } else {
            return second > a.second;
        }
    }
};

int32_t main() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i ++) {
        cin >> v[i];
    } 
    for(int i = 1; i <= n; i ++){
        cin >> b[i];
    }
    set<pairing> pq;
    for(int i = 1; i <= n; i ++) {
        pq.insert({max(v[i], b[i]), i});
        cnt[i] = 1;
    }
    for(int i = 2; i <= k; i ++) {
        for(int j = 1; j <= n; j ++) {
            pairing curr = *(pq.begin());
            int sum = curr.first, ind = curr.second;
            pq.erase({sum, ind});
            if(cnt[ind] < k) {
                sum += max(v[ind], b[ind]);
                cnt[ind] ++;
            } else {
                sum +=  b[ind];
            }
            pq.insert({sum, ind});
        }
    } 
    int minn = 1e18;
    for(auto it : pq) {
        // cout << it.first << " " << it.second << endl;
        minn = min(minn, it.first);
    }
    cout << minn;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 700 KB Output is correct
11 Correct 303 ms 27336 KB Output is correct
12 Correct 302 ms 27392 KB Output is correct
13 Correct 187 ms 27344 KB Output is correct
14 Correct 195 ms 27340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 130 ms 26692 KB Output is correct
17 Correct 250 ms 27308 KB Output is correct
18 Correct 308 ms 27364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 130 ms 26692 KB Output is correct
3 Correct 250 ms 27308 KB Output is correct
4 Correct 308 ms 27364 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 157 ms 14412 KB Output is correct
14 Correct 114 ms 10124 KB Output is correct
15 Correct 79 ms 7492 KB Output is correct
16 Correct 94 ms 6056 KB Output is correct
17 Correct 27 ms 340 KB Output is correct
18 Correct 21 ms 308 KB Output is correct
19 Correct 17 ms 212 KB Output is correct
20 Correct 10 ms 212 KB Output is correct
21 Correct 10 ms 324 KB Output is correct
22 Correct 50 ms 696 KB Output is correct
23 Correct 53 ms 800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 700 KB Output is correct
11 Correct 303 ms 27336 KB Output is correct
12 Correct 302 ms 27392 KB Output is correct
13 Correct 187 ms 27344 KB Output is correct
14 Correct 195 ms 27340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 157 ms 14412 KB Output is correct
24 Correct 114 ms 10124 KB Output is correct
25 Correct 79 ms 7492 KB Output is correct
26 Correct 94 ms 6056 KB Output is correct
27 Correct 27 ms 340 KB Output is correct
28 Correct 21 ms 308 KB Output is correct
29 Correct 17 ms 212 KB Output is correct
30 Correct 10 ms 212 KB Output is correct
31 Correct 10 ms 324 KB Output is correct
32 Correct 50 ms 696 KB Output is correct
33 Correct 53 ms 800 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 130 ms 26692 KB Output is correct
36 Correct 250 ms 27308 KB Output is correct
37 Correct 308 ms 27364 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 308 KB Output is correct
41 Correct 1 ms 308 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 39 ms 844 KB Output is correct
46 Correct 10 ms 1260 KB Output is correct
47 Correct 7 ms 340 KB Output is correct
48 Correct 51 ms 5680 KB Output is correct
49 Correct 2 ms 212 KB Output is correct
50 Correct 34 ms 304 KB Output is correct
51 Correct 46 ms 796 KB Output is correct
52 Correct 10 ms 212 KB Output is correct
53 Correct 26 ms 320 KB Output is correct
54 Correct 29 ms 308 KB Output is correct
55 Correct 184 ms 16012 KB Output is correct
56 Correct 103 ms 10080 KB Output is correct
57 Correct 104 ms 10076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 157 ms 14412 KB Output is correct
10 Correct 114 ms 10124 KB Output is correct
11 Correct 79 ms 7492 KB Output is correct
12 Correct 94 ms 6056 KB Output is correct
13 Correct 27 ms 340 KB Output is correct
14 Correct 21 ms 308 KB Output is correct
15 Correct 17 ms 212 KB Output is correct
16 Correct 10 ms 212 KB Output is correct
17 Correct 10 ms 324 KB Output is correct
18 Correct 50 ms 696 KB Output is correct
19 Correct 53 ms 800 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 130 ms 26692 KB Output is correct
22 Correct 250 ms 27308 KB Output is correct
23 Correct 308 ms 27364 KB Output is correct
24 Execution timed out 1075 ms 4808 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 700 KB Output is correct
11 Correct 303 ms 27336 KB Output is correct
12 Correct 302 ms 27392 KB Output is correct
13 Correct 187 ms 27344 KB Output is correct
14 Correct 195 ms 27340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 157 ms 14412 KB Output is correct
24 Correct 114 ms 10124 KB Output is correct
25 Correct 79 ms 7492 KB Output is correct
26 Correct 94 ms 6056 KB Output is correct
27 Correct 27 ms 340 KB Output is correct
28 Correct 21 ms 308 KB Output is correct
29 Correct 17 ms 212 KB Output is correct
30 Correct 10 ms 212 KB Output is correct
31 Correct 10 ms 324 KB Output is correct
32 Correct 50 ms 696 KB Output is correct
33 Correct 53 ms 800 KB Output is correct
34 Correct 1 ms 308 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 308 KB Output is correct
37 Correct 1 ms 308 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 39 ms 844 KB Output is correct
42 Correct 10 ms 1260 KB Output is correct
43 Correct 7 ms 340 KB Output is correct
44 Correct 51 ms 5680 KB Output is correct
45 Correct 2 ms 212 KB Output is correct
46 Correct 34 ms 304 KB Output is correct
47 Correct 46 ms 796 KB Output is correct
48 Correct 10 ms 212 KB Output is correct
49 Correct 26 ms 320 KB Output is correct
50 Correct 29 ms 308 KB Output is correct
51 Correct 184 ms 16012 KB Output is correct
52 Correct 103 ms 10080 KB Output is correct
53 Correct 104 ms 10076 KB Output is correct
54 Execution timed out 1075 ms 4808 KB Time limit exceeded
55 Halted 0 ms 0 KB -