# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034557 | 0pt1mus23 | Table Tennis (info1cup20_tabletennis) | C++14 | 90 ms | 12292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
I used Nelt's sol as editorial : https://oj.uz/submission/766955
*/
#pragma GCC optimize("O3", "inline")
#define skillissue <bits/stdc++.h>
#define ultra_mal std
#include skillissue
using namespace ultra_mal;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ins insert
#define pb push_back
#define int long long int
#define pii pair<int, int>
#define endl '\n'
#define drop(x) cout<<(x)<<endl; return;
#define all(x) x.begin(),x.end()
#define hash FhashF
const int mod = 1e9 +7, sze = 2e5 +10, inf = LLONG_MAX, P = 1453;
void optimus(){
int n,k;
cin>>n>>k;
vector<int> arr(n);
for(int i=0;i<n;i++){
cin>>arr[i];
}
vector<int> kar(k);
for(int i=0;i<k;i++){
cin>>kar[i];
}
set<int> lst;
for(int i=0;i<n/2;i++){
lst.insert(arr[i]+arr[n - i-1]);
}
if(lst.size()==1){
for(auto v:arr){
cout<<v<<" ";
}
cout<<endl;
return;
}
vector<int> brr=arr;
for(auto v:kar){
brr.pb(v);
}
for(int i =0;i<n+k;i++){
for(int j=i+n-1;j<n+k;j++){
int cnt=j-i+1;
vector<int> ans;
int l = i;
int r=j;
while(l<r){
if(brr[l]+brr[r]==brr[i]+brr[j]){
ans.pb(brr[l]);
ans.pb(brr[r]);
l++;
r--;
}
else if(brr[l]+brr[r]>brr[i]+brr[j]){
cnt--;
r--;
}
else{
cnt--;
l++;
}
if(cnt<n || ans.size()>=n){
break;
}
}
if(cnt==n){
sort(all(ans));
for(auto v:ans){
cout<<v<<" ";
}
cout<<endl;
return;
}
}
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int tt = 1;
// cin>>tt;
while(tt--){
optimus();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |