Submission #718294

# Submission time Handle Problem Language Result Execution time Memory
718294 2023-04-03T19:52:17 Z vjudge1 Table Tennis (info1cup20_tabletennis) C++17
34 / 100
68 ms 5272 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;
    ll a[min(n + k - 1, k*2) + 1], b[min(n + k - 1, k*2) + 1];
    for(int i=0;i<=min(n + k - 1, k*2);i++)
        a[i] = arr[i];
    reverse(arr, arr + n + k);
    for(int i=0;i<=min(n + k - 1, k*2);i++)
        b[i] = arr[i];
    map<int, int> mp;
    vector<int> f;
    int mx = 0;
    for(ll i : a){
        for(ll j : b){
            if(i == j)
                continue;
            mx = max(mx, ++mp[i + j]);
            f.push_back(i + j);
        }
    }
    vector<int> vec;
    for(int i : f){
        if(mp[i] >= k)
            vec.push_back(i);
        // cout << i << endl;
    }
    reverse(arr, arr + n + k);
    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:43:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |             if(ans.size() == n)
      |                ~~~~~~~~~~~^~~~
tabletennis.cpp:54:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |         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 7 ms 724 KB Output is correct
2 Correct 34 ms 3208 KB Output is correct
3 Correct 31 ms 3016 KB Output is correct
4 Correct 31 ms 3104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 3068 KB Output is correct
2 Correct 32 ms 3152 KB Output is correct
3 Correct 31 ms 3092 KB Output is correct
4 Correct 31 ms 2984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 852 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 1 ms 212 KB Output is correct
3 Incorrect 0 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 340 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 68 ms 5272 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -