Submission #718289

# Submission time Handle Problem Language Result Execution time Memory
718289 2023-04-03T19:42:36 Z haxorman Table Tennis (info1cup20_tabletennis) C++14
20 / 100
156 ms 41804 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int mxN = 2e5 + 7;

int arr[mxN];

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int n, k;
    cin >> n >> k;
    
    map<int,bool> in;
    for (int i = 0; i < n + k; ++i) {
        cin >> arr[i];
        in[arr[i]] = true;
    }
    
    map<int,int> freq;
    for (int i = 0; i < k + 2;  ++i) {
        for (int j = n + k - 1; j >= n - 1; --j) {
            int sum = arr[i] + arr[j];
            freq[sum]++;

        }
    }

    for (auto p : freq) {
        if (p.second >= k) {
            int sum = p.first;
            vector<int> nums;
            for (int l = 0; l < n + k; ++l) {
                if (sum - arr[l] >= 0 && in[sum - arr[l]]) {
                    nums.push_back(arr[l]);
                }
            }

            if (nums.size() >= n) {
                for (int l = 0; l < n; ++l) {
                    cout << nums[l] << ' ';
                }
                cout << "\n";
                exit(0);
            }
        }
    }
}
// 1 2 1 2 3

Compilation message

tabletennis.cpp: In function 'int32_t main()':
tabletennis.cpp:41:29: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   41 |             if (nums.size() >= n) {
      |                 ~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 852 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2352 KB Output is correct
2 Correct 156 ms 41804 KB Output is correct
3 Correct 72 ms 13628 KB Output is correct
4 Correct 72 ms 13572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 13604 KB Output is correct
2 Incorrect 45 ms 10760 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 852 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 1 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 5964 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -