# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
888306 | 2023-12-16T22:14:29 Z | raul2008487 | Table Tennis (info1cup20_tabletennis) | C++17 | 27 ms | 6252 KB |
/// R #include <bits/stdc++.h> #define ll long long #define pb push_back #define fi first #define se second #define all(v) v.begin(), v.end() #define in insert #define mpr make_pair #define vl vector<ll> #define endl '\n' using namespace std; const int sz = 2e5+5; const ll inf = 1000000000000000; //tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> rbt;a /*struct DSU{ vector<ll> e; void init(ll n){ e.assign(n+1, -1); } ll base(ll x){ if(e[x] < 0){ return x; } return e[x] = base(e[x]); } bool unite(ll a, ll b){ a = base(a); b = base(b); if(a == b){return false;} if(e[a] > e[b]){ swap(a, b); } e[a] += e[b]; e[b] = a; return true; } };*/ ll n, k, m; vl d, v(sz); void print(ll bg, ll ed, ll pos){ ll l = bg, r = ed, s1 = d[bg], s2 = d[ed]; vl bad, res; while(l < r && pos <= k){ if(s1 == s2){ l++; r--; } else if(s1 < s2){ l++; bad.pb(l); s1 += d[l]; } else{ bad.pb(r); r--; s2 += d[r]; } } ll ptr = 0; for(int g = bg; g <= ed+1; g++){ if(ptr < bad.size() && bad[ptr] == g){ptr++;continue;} res.pb(v[g]); } for(auto x: res){ cout << x << ' '; } cout << endl; } bool check(ll bg, ll ed, ll pos){ ll l = bg, r = ed, s1 = d[bg], s2 = d[ed]; ll cnt = 1; if( l > r){return false;} bool tmr = 1; while(l < r && pos <= k){ if(s1 == s2){ l++; r--; cnt++; tmr = 1; continue; } else if(s1 < s2){ l++; pos++; s1 += d[l]; } else{ r--; pos++; s2 += d[r]; } tmr = 0; } return (cnt == (n/2) && pos == k && (tmr)); } void solve(){ ll i, j, bg, ed, pt, w1, w2, cnt, l, r, cc; cin>>n>>k; m = n + k; for(i=0;i<m;i++){ cin>>v[i]; } for(i=1;i<m;i++){ d.pb(v[i] - v[i-1]); } for(i=0;i<=k;i++){ for(j=0;j<=k-i;j++){ if(check(i, m - 2 - j, i + j)){ print(i, m - 2 - j, i + j); return ; } } } assert(0); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t=1; //cin>>t; while(t--){ solve(); } } /* 6 3 1 2 3 6 7 9 10 12 14 1 3 6 7 10 12 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1884 KB | Output is correct |
2 | Correct | 2 ms | 1884 KB | Output is correct |
3 | Correct | 1 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 2680 KB | Output does not have symmetry property |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 6100 KB | Output is correct |
2 | Correct | 27 ms | 6100 KB | Output is correct |
3 | Correct | 22 ms | 6100 KB | Output is correct |
4 | Correct | 22 ms | 6100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1884 KB | Output is correct |
2 | Correct | 1 ms | 1884 KB | Output is correct |
3 | Correct | 1 ms | 1884 KB | Output is correct |
4 | Correct | 1 ms | 1884 KB | Output is correct |
5 | Correct | 1 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1880 KB | Output is correct |
2 | Correct | 1 ms | 1884 KB | Output is correct |
3 | Correct | 1 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1884 KB | Output is correct |
2 | Correct | 1 ms | 1884 KB | Output is correct |
3 | Correct | 1 ms | 1884 KB | Output is correct |
4 | Correct | 1 ms | 1884 KB | Output is correct |
5 | Correct | 1 ms | 1884 KB | Output is correct |
6 | Incorrect | 1 ms | 1884 KB | Output does not have symmetry property |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1884 KB | Output is correct |
2 | Incorrect | 23 ms | 6100 KB | Output does not have symmetry property |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1884 KB | Output is correct |
2 | Incorrect | 27 ms | 6252 KB | Output does not have symmetry property |
3 | Halted | 0 ms | 0 KB | - |