Submission #718302

# Submission time Handle Problem Language Result Execution time Memory
718302 2023-04-03T20:04:49 Z vjudge1 Table Tennis (info1cup20_tabletennis) C++17
34 / 100
35 ms 4576 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(x) x.begin(),x.end()
const int MOD = 1e9 + 7, SZ = 1e5 + 10, MX = 1e9;
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    int arr[n + k];
    for(int &i : arr)
        cin >> i;
    map<int, int> frq;
    vector<int> vec;
    for(int i=0;i<=min(k*2, n + k - 1);i++){
        for(int j=0;j<=min(k*2, n + k - 1);j++){
            ll x = arr[i] + arr[n + k - j - 1];
            if(++frq[x] == k)
                vec.push_back(x);
        }
    }
    for(ll i : vec){
        vector<int> ans;
        int l = 0, r = n + k - 1;
        while(l < r){
            ll x = arr[l] + arr[r];
            if(ans.size() == n)
                break;
            if(x == i){
                ans.push_back(arr[l]);
                ans.push_back(arr[r]);
            }
            if(x >= i)
                r--;
            if(x <= i)
                l++;
        }
        if(ans.size() == n){
            sort(all(ans));
            for(int x : ans)
                cout << x << ' ';
            break;
        }
    }
    return 0;
}
// https://www.youtube.com/watch?v=zL32whN6p0A&ab_channel=HeidiAdel-CartoonWorld

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:28:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |             if(ans.size() == n)
      |                ~~~~~~~~~~~^~~~
tabletennis.cpp:39:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |         if(ans.size() == n){
      |            ~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 724 KB Output is correct
2 Correct 32 ms 3020 KB Output is correct
3 Correct 32 ms 3068 KB Output is correct
4 Correct 32 ms 3024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 3064 KB Output is correct
2 Correct 31 ms 3024 KB Output is correct
3 Correct 32 ms 3084 KB Output is correct
4 Correct 32 ms 3112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 724 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 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 35 ms 4576 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -