답안 #815955

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815955 2023-08-09T02:55:51 Z vjudge1 Self Study (JOI22_ho_t2) C++17
35 / 100
67 ms 11424 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

void open(){
	if(fopen("input.inp", "r")){
		freopen("input.inp", "r", stdin);
		//freopen("output.out", "w", stdout);
	}
}

const int maxn = 3e5 + 5;
int n, m;
int A[maxn], B[maxn];

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	open();
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> A[i];
	}

	for(int i = 1; i <= n; i++){
		cin >> B[i];
	}

	if(m == 1){
		int result = 1e9 + 7;
		for(int i = 1; i <= n; i++){
			result = min(result, max(A[i], B[i]));
		}

		cout << result << endl;
		return 0;
	}

	if(m * n <= maxn){
		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
		for(int i = 1; i <= n; i++){
			pq.push({0, i});
		}
		while(m--){
			int temp = n;
			while(temp--){
				pair<int, int> first = pq.top();
				pq.pop();
				int old_val = first.first;
				int pos = first.second;
				old_val += A[pos];
				pq.push({old_val, pos});
			}
		}

		cout << pq.top().first << endl;
	}

	return 0;
}

Compilation message

Main.cpp: In function 'void open()':
Main.cpp:8:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   freopen("input.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 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 0 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 66 ms 8608 KB Output is correct
12 Correct 49 ms 10800 KB Output is correct
13 Correct 38 ms 8804 KB Output is correct
14 Correct 49 ms 8804 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 24 ms 6076 KB Output is correct
17 Correct 50 ms 11424 KB Output is correct
18 Correct 67 ms 10740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 24 ms 6076 KB Output is correct
3 Correct 50 ms 11424 KB Output is correct
4 Correct 67 ms 10740 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 57 ms 9720 KB Output is correct
14 Correct 51 ms 5972 KB Output is correct
15 Correct 34 ms 5084 KB Output is correct
16 Correct 42 ms 3540 KB Output is correct
17 Correct 18 ms 460 KB Output is correct
18 Correct 9 ms 212 KB Output is correct
19 Correct 7 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 5 ms 360 KB Output is correct
22 Correct 19 ms 632 KB Output is correct
23 Correct 18 ms 596 KB Output is correct
# 결과 실행 시간 메모리 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 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 0 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 66 ms 8608 KB Output is correct
12 Correct 49 ms 10800 KB Output is correct
13 Correct 38 ms 8804 KB Output is correct
14 Correct 49 ms 8804 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 57 ms 9720 KB Output is correct
24 Correct 51 ms 5972 KB Output is correct
25 Correct 34 ms 5084 KB Output is correct
26 Correct 42 ms 3540 KB Output is correct
27 Correct 18 ms 460 KB Output is correct
28 Correct 9 ms 212 KB Output is correct
29 Correct 7 ms 212 KB Output is correct
30 Correct 4 ms 212 KB Output is correct
31 Correct 5 ms 360 KB Output is correct
32 Correct 19 ms 632 KB Output is correct
33 Correct 18 ms 596 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 24 ms 6076 KB Output is correct
36 Correct 50 ms 11424 KB Output is correct
37 Correct 67 ms 10740 KB Output is correct
38 Incorrect 0 ms 224 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 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 57 ms 9720 KB Output is correct
10 Correct 51 ms 5972 KB Output is correct
11 Correct 34 ms 5084 KB Output is correct
12 Correct 42 ms 3540 KB Output is correct
13 Correct 18 ms 460 KB Output is correct
14 Correct 9 ms 212 KB Output is correct
15 Correct 7 ms 212 KB Output is correct
16 Correct 4 ms 212 KB Output is correct
17 Correct 5 ms 360 KB Output is correct
18 Correct 19 ms 632 KB Output is correct
19 Correct 18 ms 596 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 24 ms 6076 KB Output is correct
22 Correct 50 ms 11424 KB Output is correct
23 Correct 67 ms 10740 KB Output is correct
24 Incorrect 11 ms 1916 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 0 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 66 ms 8608 KB Output is correct
12 Correct 49 ms 10800 KB Output is correct
13 Correct 38 ms 8804 KB Output is correct
14 Correct 49 ms 8804 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 57 ms 9720 KB Output is correct
24 Correct 51 ms 5972 KB Output is correct
25 Correct 34 ms 5084 KB Output is correct
26 Correct 42 ms 3540 KB Output is correct
27 Correct 18 ms 460 KB Output is correct
28 Correct 9 ms 212 KB Output is correct
29 Correct 7 ms 212 KB Output is correct
30 Correct 4 ms 212 KB Output is correct
31 Correct 5 ms 360 KB Output is correct
32 Correct 19 ms 632 KB Output is correct
33 Correct 18 ms 596 KB Output is correct
34 Incorrect 0 ms 224 KB Output isn't correct
35 Halted 0 ms 0 KB -