Submission #718277

# Submission time Handle Problem Language Result Execution time Memory
718277 2023-04-03T19:33:44 Z vjudge1 Table Tennis (info1cup20_tabletennis) C++17
72 / 100
46 ms 4500 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[k + 1], b[k + 1];
    for(int i=0;i<=k;i++)
        a[i] = arr[i];
    reverse(arr, arr + n + k);
    for(int i=0;i<=k;i++)
        b[i] = arr[i];
    map<int, int> mp;
    vector<int> f;
    int mx = 0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k-i;j++){
            // if(i == j)
            //     continue;
            mx = max(mx, ++mp[arr[i] + arr[n + k - j - 1]]);
            f.push_back(arr[i] + arr[n + k - j - 1]);
        }
    }
    vector<int> vec;
    for(int i : f){
        if(mp[i] == mx)
            vec.push_back(i);
    }
    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:42:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |             if(ans.size() == n)
      |                ~~~~~~~~~~~^~~~
tabletennis.cpp:53:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |         if(ans.size() == n){
      |            ~~~~~~~~~~~^~~~
tabletennis.cpp:14:8: warning: variable 'a' set but not used [-Wunused-but-set-variable]
   14 |     ll a[k + 1], b[k + 1];
      |        ^
tabletennis.cpp:14:18: warning: variable 'b' set but not used [-Wunused-but-set-variable]
   14 |     ll a[k + 1], b[k + 1];
      |                  ^
# 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 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 980 KB Output is correct
2 Correct 33 ms 4416 KB Output is correct
3 Correct 42 ms 4420 KB Output is correct
4 Correct 32 ms 4436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 4472 KB Output is correct
2 Correct 34 ms 4500 KB Output is correct
3 Correct 36 ms 4412 KB Output is correct
4 Correct 35 ms 4424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 576 KB Output is correct
2 Incorrect 1 ms 468 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 33 ms 4408 KB Output is correct
3 Correct 32 ms 4412 KB Output is correct
4 Correct 34 ms 4360 KB Output is correct
5 Correct 35 ms 4448 KB Output is correct
6 Correct 46 ms 4412 KB Output is correct
7 Correct 36 ms 4496 KB Output is correct
8 Correct 32 ms 4400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 4324 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -