Submission #957094

#TimeUsernameProblemLanguageResultExecution timeMemory
957094MuntherCarrotTable Tennis (info1cup20_tabletennis)C++14
100 / 100
203 ms33996 KiB
#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; if(k*4 >= n + k){ for(int i=0;i<n+k;i++){ for(int j=i+1;j<n+k;j++) vec.push_back(arr[i] + arr[j]); } } else{ for(int i=0;i<=k*2;i++){ for(int j=0;j<=k*2;j++){ if(i >= n + k - j - 1) break; 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 (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:38:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |             if(ans.size() == n)
      |                ~~~~~~~~~~~^~~~
tabletennis.cpp:49:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |         if(ans.size() == n){
      |            ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...