제출 #922292

#제출 시각아이디문제언어결과실행 시간메모리
922292IanisTable Tennis (info1cup20_tabletennis)C++17
11 / 100
3032 ms3944 KiB
#ifdef LOCAL #include <iostream> #include <fstream> #include <iomanip> #include <cassert> #include <random> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #else #pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> #define cerr if (false) cerr #define endl '\n' #endif #define fi first #define se second #define sz(a) ((int)(a).size()) #define all(a) (a).begin(), (a).end() #define lsb(x) (x & (-x)) #define bit(mask, i) (((mask) >> (i)) & 1) #define popcount(x) __builtin_popcount(x) #define YES cout << "YES" << endl #define NO cout << "NO" << endl using namespace std; template <typename T> bool ckmax(T &a, T b) { return a < b ? a = b, true : false; } template <typename T> bool ckmin(T &a, T b) { return a > b ? a = b, true : false; } using ll = long long; using pii = pair<int, int>; const int NMAX = 15e4+5; int n, k, m; int a[NMAX]; void read() { cin >> n >> k; m = n + k; for (int i = 1; i <= m; i++) { cin >> a[i]; } } void check(vector<int> v) { int n = int(v.size()); assert(n % 2 == 0); for (int mask = 1; mask < 1 << n; mask++) { if (popcount(mask) != n / 2) continue; ll sum1 = 0, sum2 = 0; for (int i = 0; i < n; i++) { if (mask & (1 << i)) sum1 += v[i]; else sum2 += v[i]; } if (sum1 == sum2) { vector<int> v1, v2; for (int i = 0; i < n; i++) { if (mask & (1 << i)) v2.push_back(v[i]); else v1.push_back(v[i]); } for (auto &it : v1) cout << it << ' '; cout << endl; for (auto &it : v2) cout << it << ' '; cout << endl; return; } } } bool check(int blocked) { int l = 1, r = m; if (blocked == l) l++; if (blocked == r) r--; int sum1 = 0, sum2 = 0; int cnt = 0; while (l < r) { cnt++; if (cnt % 2) sum1 += a[l] + a[r]; else sum2 += a[l] + a[r]; l++; if (l == blocked) l++; r--; if (r == blocked) r--; } return sum1 == sum2; } void solve() { for (int i = 1; i <= m; i++) { if (check(i)) { for (int j = 1; j <= m; j++) { if (j != i) cout << a[j] << ' '; } cout << endl; return; } } } signed main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); read(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...