# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
667726 | ar_paixaos19 | Table Tennis (info1cup20_tabletennis) | C++14 | 3076 ms | 3984 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);
bool busca(int i, int j, int n){
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){
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;
for(int i = n; i <= n + k, !achou; i++){
for(int j = i + 1; j <= n + k + 1; j++){
if(busca(i, j, n)){
achou = true;
//printf("achou %d %d\n", i, j);
goto NEXT;
}
resp.clear();
}
}
NEXT:;
sort(resp.begin(), resp.end());
if(resp.empty()){
printf("penis\n");
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... |