# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
668366 | ar_paixaos19 | Table Tennis (info1cup20_tabletennis) | C++14 | 3058 ms | 4044 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.
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
const int MAXN = 150010;
const int MAXK = 410;
int v[MAXN + MAXK];
bool mark[MAXN + MAXK];
vector<pair<int, int>> resp(MAXN + MAXK);
bool busca(int i, int j, int n, int k){
resp.clear();
resp.pb(mp(i, j));
//printf("estou testando o meio %d %d\n", i, j);
int s = v[i] + v[j];
int q = j + 1;
int qtd = 1;
for(int p = i - 1; p >= 1; p--){
while(v[p] + v[q] < s && q <= 2 * n + k){
q++;
}
if(v[p] + v[q] == s){
//printf("v[%d] + v[%d] funcionou\n", p, q);
resp.pb(mp(p, q));
qtd++;
q++;
}
if(qtd == n){
//printf("acabei o prob com meio %d %d\n", i, j);
return true;
}
}
return false;
}
int main(){
int N, k; scanf("%d %d", &N, &k);
for(int i = 1; i <= N + k; i++){
scanf("%d", &v[i]);
}
int n = N / 2;
bool achou = false;
int minmid = max(1,n-3), maxmid = min(N+k,n+k+3);
for(int i = minmid; i <= maxmid && !achou; i++){
for(int j = i+1; j <= maxmid; j++){
if(busca(i, j, n, k)){
achou = true;
//printf("achou %d %d\n", i, j);
break;
}
}
}
sort(resp.begin(), resp.end());
if(resp.size() < n){
printf("%dpenis%d\n", n,resp.size());
return 0;
}
for(int i = 0; i < n; i++){
printf("%d ", v[resp[i].first]);
}
for(int i = n - 1; i >= 0; i--){
printf("%d ", v[resp[i].second]);
}
printf("\n");
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... |