#include <bits/stdc++.h>
#ifdef local
#define debug(a...) qqbx(#a, a)
template <typename ...T> void qqbx(const char *s, T ...a) {
int cnt = sizeof...(T);
((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n")));
}
#define pary(a...) danb(#a, a)
template <typename T> void danb(const char *s, T L, T R) {
std::cerr << "\033[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L) std::cerr << (f++ ? " " : "") << *L;
std::cerr << " ]\033[0m\n";
}
#else
#define debug(...) ((void)0)
#define pary(...) ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define pb emplace_back
using namespace std;
using ll = int64_t;
const int inf = 1e9, MOD = 1000000007, maxn = 1 << 18, maxLg = 18;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, k;
cin >> n >> k;
int m = n+k;
vector<int> a(m);
for (int i = 0; i < m; i++)
cin >> a[i];
int lim = min(m / 2, k * 2);
vector<int> jizz(a.begin(), a.begin() + lim);
jizz.insert(jizz.end(), a.end() - lim, a.end());
map<int,int> freq;
for (int x: jizz) for (int y: jizz) if (x < y) ++freq[x+y];
for (auto [val, cnt]: freq) if (cnt >= 0) {
debug(val);
vector<int> cur;
for (int i = 0, j = a.size()-1; i < j; i++) {
while (j > i && a[j] > val - a[i]) --j;
if (j > i && a[j] + a[i] == val)
cur.pb(a[i]), cur.pb(a[j]);
}
if (cur.size() == n) {
sort(all(cur));
for (int x: cur)
cout << x << ' ';
cout << '\n';
return 0;
}
}
}
Compilation message
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:40:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
40 | for (auto [val, cnt]: freq) if (cnt >= 0) {
| ^
tabletennis.cpp:48:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
48 | if (cur.size() == n) {
| ~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
764 KB |
Output is correct |
2 |
Correct |
41 ms |
3080 KB |
Output is correct |
3 |
Correct |
39 ms |
3080 KB |
Output is correct |
4 |
Correct |
39 ms |
3088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
3040 KB |
Output is correct |
2 |
Correct |
41 ms |
3132 KB |
Output is correct |
3 |
Correct |
42 ms |
3036 KB |
Output is correct |
4 |
Correct |
52 ms |
3060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
716 KB |
Output is correct |
2 |
Correct |
9 ms |
972 KB |
Output is correct |
3 |
Correct |
4 ms |
972 KB |
Output is correct |
4 |
Correct |
5 ms |
972 KB |
Output is correct |
5 |
Correct |
4 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
4 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
5 |
Correct |
5 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
945 ms |
3216 KB |
Output is correct |
3 |
Correct |
68 ms |
3128 KB |
Output is correct |
4 |
Correct |
107 ms |
3156 KB |
Output is correct |
5 |
Correct |
52 ms |
3112 KB |
Output is correct |
6 |
Correct |
128 ms |
4056 KB |
Output is correct |
7 |
Correct |
117 ms |
3120 KB |
Output is correct |
8 |
Correct |
107 ms |
3060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
4540 KB |
Output is correct |
2 |
Execution timed out |
3053 ms |
54240 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |