Submission #328946

# Submission time Handle Problem Language Result Execution time Memory
328946 2020-11-18T14:43:19 Z ThaiBaHung Table Tennis (info1cup20_tabletennis) C++14
87 / 100
3000 ms 4632 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 160003;
const int K = 403;
int n, k;
int a[N];

void solve(int lo, int hi, int sum)
{
    vector < int > res;
    int cur = 1;

    res.push_back(a[lo]), res.push_back(a[hi]);

    int i = lo + 1, j = hi - 1;

    while (i < j)
    {
        if (a[i] + a[j] > sum) j--;
        if (a[i] + a[j] < sum) i++;
        if (a[i] + a[j] == sum)
        {
            cur++;
            res.push_back(a[i]);
            res.push_back(a[j]);
            i++; j--;
        }
    }

    if (cur == n / 2)
    {
        sort(res.begin(), res.end());

        for (int u : res)
            cout << u << " ";
        exit(0);
    }

    return;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> k;

    int m = n + k;

    for (int i = 1; i <= m; i++)
        cin >> a[i];

    sort(a + 1, a + m + 1);

    for (int i = 1; i <= k + 1; i++)
    {
        for (int j = i + n - 1; j <= m; j++)
        {
            solve(i, j, a[i] + a[j]);
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1052 KB Output is correct
2 Correct 43 ms 4584 KB Output is correct
3 Correct 43 ms 4584 KB Output is correct
4 Correct 42 ms 4584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 4584 KB Output is correct
2 Correct 42 ms 4584 KB Output is correct
3 Correct 43 ms 4584 KB Output is correct
4 Correct 43 ms 4584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 185 ms 4584 KB Output is correct
3 Correct 42 ms 4584 KB Output is correct
4 Correct 70 ms 4632 KB Output is correct
5 Correct 43 ms 4584 KB Output is correct
6 Correct 59 ms 4584 KB Output is correct
7 Correct 58 ms 4576 KB Output is correct
8 Correct 43 ms 4624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 3078 ms 2412 KB Time limit exceeded
3 Halted 0 ms 0 KB -