Submission #1028352

# Submission time Handle Problem Language Result Execution time Memory
1028352 2024-07-19T17:08:07 Z sqrteipi A Plus B (IOI23_aplusb) C++17
100 / 100
34 ms 5840 KB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>

vector<int> smallest_sums(int n, vector<int> a, vector<int> b) {
  sort(b.begin(), b.end());
  int ptr[n], p=0;
  vector<int> ans;
  priority_queue<pii, vector<pii>, greater<pii>> pq;
  for (int i=0; i<n; i++) pq.push({a[i] + b[0], i});
  for (int i=0; i<n; i++) ptr[i] = 1;
  while (!pq.empty()) {
    if (ans.size() == n) break;
    ans.push_back(pq.top().first);
    int ind = pq.top().second; 
    pq.pop();
    if (ptr[ind] == n) continue;
    pq.push({a[ind] + b[ptr[ind]], ind});
    ptr[ind]++;
  }
  return ans;
}

Compilation message

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:13:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |     if (ans.size() == n) break;
      |         ~~~~~~~~~~~^~~~
aplusb.cpp:7:15: warning: unused variable 'p' [-Wunused-variable]
    7 |   int ptr[n], p=0;
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 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 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 2 ms 444 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 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 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 2 ms 444 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 6 ms 1496 KB Output is correct
38 Correct 22 ms 4560 KB Output is correct
39 Correct 23 ms 4560 KB Output is correct
40 Correct 24 ms 4560 KB Output is correct
41 Correct 31 ms 5832 KB Output is correct
42 Correct 32 ms 5840 KB Output is correct
43 Correct 28 ms 5284 KB Output is correct
44 Correct 6 ms 1496 KB Output is correct
45 Correct 31 ms 4648 KB Output is correct
46 Correct 23 ms 4560 KB Output is correct
47 Correct 23 ms 4544 KB Output is correct
48 Correct 31 ms 5832 KB Output is correct
49 Correct 32 ms 5792 KB Output is correct
50 Correct 31 ms 5328 KB Output is correct
51 Correct 34 ms 5172 KB Output is correct
52 Correct 34 ms 5064 KB Output is correct
53 Correct 33 ms 5072 KB Output is correct