Submission #717894

# Submission time Handle Problem Language Result Execution time Memory
717894 2023-04-02T19:41:23 Z vjudge1 Table Tennis (info1cup20_tabletennis) C++17
34 / 100
87 ms 4312 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define endl '\n'
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
const int mod = 1e9 + 7;
const int N = 1e6 + 15;
const ll inf = 1e18;
int n,k,o;
vector<int> a;
int solve(int x){
  int p1=0,p2=n-1;
  int cur = 0;
  while (p1<p2){
    if (a[p1]+a[p2]==x){
      cur+=2;
      p1++;p2--;
    }
    else if (a[p1]+a[p2] < x){
      p1++;
    }
    else if (a[p1]+a[p2] > x){
      p2--;
    }
  }
  return cur;
}
void print(int x){
  int p1=0,p2=n-1;
  vector<int> ans;
  while (p1<p2){
    if (a[p1]+a[p2]==x){
      ans.pb(a[p1]);
      ans.pb(a[p2]);
      if (sz(ans)==o) break;
      p1++;p2--;
    }
    else if (a[p1]+a[p2] < x){
      p1++;
    }
    else if (a[p1]+a[p2] > x){
      p2--;
    }
  }
  sort(all(ans));
  for (auto it :ans){
    cout << it << ' ';
  }
  return;
}
int32_t main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
  cin >> n >> k;
  o = n;
  n = n+k;
  a.resize(n);
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  k = min(k+1,n/2 + 1);
  int ans = -1;
  for (int i=0;i<k;i++){
    for (int j=0;j<k;j++){
      if (solve(a[i]+a[n-1-j])>=o){
        ans = a[i]+a[n-1-j]; 
        break;
      }
    }
    if (ans!=-1) break;
  }
  print(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 856 KB Output is correct
2 Correct 31 ms 4244 KB Output is correct
3 Correct 30 ms 4164 KB Output is correct
4 Correct 30 ms 4228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 4300 KB Output is correct
2 Correct 30 ms 4220 KB Output is correct
3 Correct 32 ms 4312 KB Output is correct
4 Correct 31 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -