답안 #788617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
788617 2023-07-20T12:18:00 Z stefanneagu Self Study (JOI22_ho_t2) C++17
10 / 100
228 ms 13236 KB
#include <iostream>
#include <queue>

using namespace std;

const int nmax = 3e5 + 7;

int v[nmax], b[nmax];

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

int 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];
    }
    priority_queue<pairing> pq;
    for(int i = 1; i <= n; i ++) {
        pq.push({max(v[i], b[i]), i});
    }
    for(int i = 2; i <= k; i ++) {
        for(int j = 1; j <= n; j ++) {
            int sum = pq.top().first, ind = pq.top().second;
            pq.pop();
            if(j == ind) {
                sum += max(v[j], b[j]);
            } else {
                sum +=  b[ind];
            }
            pq.push({sum, ind});
        }
    } 
    int minn = 1e18;
    while(!pq.empty()) {
        minn = min(minn, pq.top().first);
        pq.pop();
    }
    cout << minn;
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:42:16: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   42 |     int minn = 1e18;
      |                ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 308 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 308 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 5 ms 452 KB Output is correct
11 Correct 217 ms 12584 KB Output is correct
12 Correct 228 ms 12636 KB Output is correct
13 Correct 153 ms 10600 KB Output is correct
14 Correct 142 ms 10652 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 82 ms 7952 KB Output is correct
17 Correct 211 ms 13236 KB Output is correct
18 Correct 219 ms 12600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 82 ms 7952 KB Output is correct
3 Correct 211 ms 13236 KB Output is correct
4 Correct 219 ms 12600 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 308 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 308 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 5 ms 452 KB Output is correct
11 Correct 217 ms 12584 KB Output is correct
12 Correct 228 ms 12636 KB Output is correct
13 Correct 153 ms 10600 KB Output is correct
14 Correct 142 ms 10652 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 308 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 308 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 5 ms 452 KB Output is correct
11 Correct 217 ms 12584 KB Output is correct
12 Correct 228 ms 12636 KB Output is correct
13 Correct 153 ms 10600 KB Output is correct
14 Correct 142 ms 10652 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -