Submission #717881

# Submission time Handle Problem Language Result Execution time Memory
717881 2023-04-02T18:38:44 Z vjudge1 Table Tennis (info1cup20_tabletennis) C++17
0 / 100
210 ms 28524 KB
#include "bits/stdc++.h"
#define ll long long
using namespace std;
const ll mod = 1000000007;

signed main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("cowland.in","r",stdin);
    // freopen("cowland.out","w",stdout);

    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> v;
    for(int i = 0; i < n + k; i++) {
        int x;
        cin >> x;
        v.push_back({x, i + 1});
    }
    sort(v.begin(), v.end());
    if(k <= 20) {
        set<int> s;
        for(int i = 0; i < k; i++) {
            int j = n + k - 1;
            while(i < j && i + ((n + k) - j - 1) <= k)
                s.insert(v[i].first + v[j--].first);
        }
        map<int, int> mp;
        bool b[n + k] = {};
        for(int x : s) {
            int y = 0;
            for(int i = 0; i < n + k; i++) {
                if(mp[x - v[i].first]) {
                    mp[x - v[i].first]--;
                    b[i] = 1;
                    y += 2;
                }
                else
                    mp[v[i].first]++;
            }
            if(y >= n) {
                int l = 0;
                set<int> ans;
                for(int r = n + k - 1; r > l && n; r--) {
                    if(!b[r])
                        continue;
                    while(l < r && v[l].first + v[r].first < x)
                        l++;
                    ans.insert(v[l++].second);
                    ans.insert(v[r].second);
                    n -= 2;
                }
                for(int i : ans)
                    cout << i << " ";
                return 0;
            }
            for(int i = 0; i < n + k; i++)
                mp[v[i].first] = 0, b[i] = 0;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 2520 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 210 ms 28524 KB Output not subsequence of input
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 1 ms 212 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output not subsequence of input
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 -