답안 #951055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951055 2024-03-21T05:19:01 Z masdav A Plus B (IOI23_aplusb) C++17
100 / 100
40 ms 5836 KB
#include<bits/stdc++.h>
using namespace std;

// #define int long long
// #define Int __int128_t
// #define dbg(x) cout<<"["<< #x <<"] : "<<(x)<<endl;
// #define bpc(x) (__builtin_popcountll(x))

int bpow(int a, int b, long long mod=LLONG_MAX){
	int res=1;while(b){if(b%2)res=res*a%mod;a=a*a%mod;b/=2;}return res;
}
int inv(int a, int mod=1e9+7){ return bpow(a, mod-2, mod); }

vector<int> smallest_sums(int n, vector<int>a, vector<int>b){	
	priority_queue<pair<int, pair<int,int>>> pq;
	for(int i = 0; i < n; i++){
		pq.push({-(a[i] + b[0]) ,{i, 0}});
	}
	// for(int i : a) dbg(i);
	// for(int i : b) dbg(i);
	
	vector<int> res;
	while((int)res.size() < n){
		int now = -pq.top().first;
		auto[now_i, now_j] = pq.top().second;

		res.push_back(now);
		pq.pop();
		pq.push({ -(a[now_i] + b[now_j+1]), {now_i, now_j + 1} });
	}
	return res;
}

// signed main(){
// 	vector<int> tmp =smallest_sums(2, {0, 2}, {1, 4});
// 	vector<int> tmp = smallest_sums(3, {0, 2, 2}, {3, 5, 6});
// 	for(int i : tmp){
// 		cout << i << ' ';
// 	}
// 	cout << '\n';
// }
/*

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 1 ms 472 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 444 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 2 ms 600 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 1 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 1 ms 472 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 444 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 2 ms 600 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 1 ms 448 KB Output is correct
37 Correct 7 ms 1568 KB Output is correct
38 Correct 32 ms 4312 KB Output is correct
39 Correct 27 ms 4568 KB Output is correct
40 Correct 30 ms 4568 KB Output is correct
41 Correct 36 ms 5836 KB Output is correct
42 Correct 39 ms 5816 KB Output is correct
43 Correct 34 ms 5328 KB Output is correct
44 Correct 7 ms 1568 KB Output is correct
45 Correct 28 ms 4716 KB Output is correct
46 Correct 28 ms 4716 KB Output is correct
47 Correct 27 ms 4608 KB Output is correct
48 Correct 37 ms 5832 KB Output is correct
49 Correct 37 ms 5832 KB Output is correct
50 Correct 35 ms 5324 KB Output is correct
51 Correct 39 ms 5052 KB Output is correct
52 Correct 40 ms 5068 KB Output is correct
53 Correct 40 ms 5164 KB Output is correct