답안 #844611

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844611 2023-09-05T14:33:01 Z denniskim A Plus B (IOI23_aplusb) C++17
100 / 100
103 ms 15920 KB
#include "aplusb.h"
#include <bits/stdc++.h>

using namespace std;
typedef int ll;

vector<ll> smallest_sums(ll N, vector<ll> A, vector<ll> B)
{
	vector<ll> ans;
	priority_queue< pair<ll, pair<ll, ll> > > pq;
	map< pair<ll, ll>, ll> mp;
	
	pq.push({-A[0] - B[0], {0, 0}});
	mp[{0, 0}] = 1;
	
	while(!pq.empty())
	{
		pair<ll, pair<ll, ll> > qq = pq.top();
		pq.pop();
		
		ans.push_back(-qq.first);
		
		if((ll)ans.size() >= N)
			break;
		
		ll p1 = qq.second.first;
		ll p2 = qq.second.second;
		
		if(p1 < N - 1)
		{
			if(mp[{p1 + 1, p2}] == 0)
			{
				mp[{p1 + 1, p2}] = 1;
				pq.push({-A[p1 + 1] - B[p2], {p1 + 1, p2}});
			}
		}
		
		if(p2 < N - 1)
		{
			if(mp[{p1, p2 + 1}] == 0)
			{
				mp[{p1, p2 + 1}] = 1;
				pq.push({-A[p1] - B[p2 + 1], {p1, p2 + 1}});
			}
		}
	}
	
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 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 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 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 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 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 600 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 2 ms 600 KB Output is correct
34 Correct 2 ms 600 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 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 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 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 600 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 2 ms 600 KB Output is correct
34 Correct 2 ms 600 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
37 Correct 15 ms 3160 KB Output is correct
38 Correct 70 ms 11956 KB Output is correct
39 Correct 59 ms 9856 KB Output is correct
40 Correct 61 ms 9860 KB Output is correct
41 Correct 67 ms 11152 KB Output is correct
42 Correct 73 ms 11268 KB Output is correct
43 Correct 103 ms 15920 KB Output is correct
44 Correct 14 ms 3012 KB Output is correct
45 Correct 58 ms 8452 KB Output is correct
46 Correct 58 ms 8452 KB Output is correct
47 Correct 59 ms 8248 KB Output is correct
48 Correct 81 ms 11392 KB Output is correct
49 Correct 81 ms 14084 KB Output is correct
50 Correct 89 ms 15848 KB Output is correct
51 Correct 78 ms 8652 KB Output is correct
52 Correct 85 ms 8648 KB Output is correct
53 Correct 79 ms 8648 KB Output is correct