# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
910879 | 2024-01-18T08:44:46 Z | vjudge1 | Table Tennis (info1cup20_tabletennis) | C++17 | 44 ms | 4940 KB |
#include <iostream> #include <vector> #include <set> #include <deque> using namespace std; const int NMAX = 150002; int v[NMAX], sum = 0, n, k; vector < int > p, im; int lb(int x){ int st = 1, dr = n + k; while(st < dr){ int mid = (st + dr) / 2; if(v[mid] >= x) dr = mid; else st = mid + 1; } return dr; } bool check(int a){ deque < int > d; int SUMA = (sum - a) / 2; int nr = 0, s1 = 0; for(int i = 1; i <= n + k; i++){ while(s1 >= SUMA){ s1 -= d.front(); nr--; d.pop_front(); } if(s1 < SUMA){ s1 += v[i]; nr++; d.push_back(v[i]); } if(s1 == SUMA && nr == n / 2) return true; } /*int st = 1, dr = n + k; if(n % 4 == 0){ ///nr par in feicare gr while(nr < n / 2){ nr += 2; if(v[st] == a) st++; if(v[dr] == a) dr--; s1 += (v[st] + v[dr]); st++, dr--; } if(s1 == SUMA) return true; cout << "s1 ii " << s1 << '\n'; } else{ while(nr < n / 2 - 1){ nr += 2; if(v[st] == a) st++; if(v[dr] == a) dr--; s1 += (v[st] + v[dr]); st++, dr--; } if(v[lb(SUMA - s1)] == SUMA - s1 && st <= lb(SUMA - s1) && lb(SUMA - s1) <= dr) return true; cout << "s1 ii " << s1 << '\n'; } return false;*/ } int solve(vector < int > a){ for(int i = 0; i < a.size(); i++){ if(check(a[i]) == true) return a[i]; cout << a[i] << '\n'; } return -1; } int main() { int remov; cin >> n >> k; for(int i = 1; i <= n + k; i++){ cin >> v[i]; sum += v[i]; if(v[i] % 2 == 0) p.push_back(v[i]); else im.push_back(v[i]); } if(sum % 2 == 1) remov = solve(im); else remov = solve(p); for(int i = 1; i <= n + k; i++){ if(v[i] != remov) cout << v[i] << " "; } return 0; } /*4 1 1 2 3 4 5*/
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 600 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 1112 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 44 ms | 4940 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 344 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 416 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 348 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 344 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 600 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |