답안 #788642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
788642 2023-07-20T12:28:14 Z stefanneagu Self Study (JOI22_ho_t2) C++17
35 / 100
1000 ms 25204 KB
#include <iostream>
#include <set>
#define int long long

using namespace std;

const int nmax = 3e5 + 7;

int v[nmax], b[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});
    }
    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;
            if(pq.find({sum, j}) != pq.end()) {
                ind = j;
            }
            pq.erase({sum, ind});
            if(j == ind) {
                sum += max(v[j], b[j]);
            } 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;
}
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 288 ms 24960 KB Output is correct
12 Correct 316 ms 25204 KB Output is correct
13 Correct 186 ms 25032 KB Output is correct
14 Correct 186 ms 25036 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 134 ms 25076 KB Output is correct
17 Correct 323 ms 24936 KB Output is correct
18 Correct 295 ms 24928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 134 ms 25076 KB Output is correct
3 Correct 323 ms 24936 KB Output is correct
4 Correct 295 ms 24928 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 158 ms 13284 KB Output is correct
14 Correct 123 ms 9360 KB Output is correct
15 Correct 84 ms 7372 KB Output is correct
16 Correct 105 ms 6260 KB Output is correct
17 Correct 33 ms 352 KB Output is correct
18 Correct 31 ms 212 KB Output is correct
19 Correct 21 ms 304 KB Output is correct
20 Correct 11 ms 212 KB Output is correct
21 Correct 11 ms 308 KB Output is correct
22 Correct 67 ms 576 KB Output is correct
23 Correct 67 ms 676 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 288 ms 24960 KB Output is correct
12 Correct 316 ms 25204 KB Output is correct
13 Correct 186 ms 25032 KB Output is correct
14 Correct 186 ms 25036 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 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 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 158 ms 13284 KB Output is correct
24 Correct 123 ms 9360 KB Output is correct
25 Correct 84 ms 7372 KB Output is correct
26 Correct 105 ms 6260 KB Output is correct
27 Correct 33 ms 352 KB Output is correct
28 Correct 31 ms 212 KB Output is correct
29 Correct 21 ms 304 KB Output is correct
30 Correct 11 ms 212 KB Output is correct
31 Correct 11 ms 308 KB Output is correct
32 Correct 67 ms 576 KB Output is correct
33 Correct 67 ms 676 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 134 ms 25076 KB Output is correct
36 Correct 323 ms 24936 KB Output is correct
37 Correct 295 ms 24928 KB Output is correct
38 Incorrect 1 ms 212 KB Output isn't correct
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 158 ms 13284 KB Output is correct
10 Correct 123 ms 9360 KB Output is correct
11 Correct 84 ms 7372 KB Output is correct
12 Correct 105 ms 6260 KB Output is correct
13 Correct 33 ms 352 KB Output is correct
14 Correct 31 ms 212 KB Output is correct
15 Correct 21 ms 304 KB Output is correct
16 Correct 11 ms 212 KB Output is correct
17 Correct 11 ms 308 KB Output is correct
18 Correct 67 ms 576 KB Output is correct
19 Correct 67 ms 676 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 134 ms 25076 KB Output is correct
22 Correct 323 ms 24936 KB Output is correct
23 Correct 295 ms 24928 KB Output is correct
24 Execution timed out 1071 ms 4764 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 288 ms 24960 KB Output is correct
12 Correct 316 ms 25204 KB Output is correct
13 Correct 186 ms 25032 KB Output is correct
14 Correct 186 ms 25036 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 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 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 158 ms 13284 KB Output is correct
24 Correct 123 ms 9360 KB Output is correct
25 Correct 84 ms 7372 KB Output is correct
26 Correct 105 ms 6260 KB Output is correct
27 Correct 33 ms 352 KB Output is correct
28 Correct 31 ms 212 KB Output is correct
29 Correct 21 ms 304 KB Output is correct
30 Correct 11 ms 212 KB Output is correct
31 Correct 11 ms 308 KB Output is correct
32 Correct 67 ms 576 KB Output is correct
33 Correct 67 ms 676 KB Output is correct
34 Incorrect 1 ms 212 KB Output isn't correct
35 Halted 0 ms 0 KB -