Submission #675119

#TimeUsernameProblemLanguageResultExecution timeMemory
675119Hiennoob123Table Tennis (info1cup20_tabletennis)C++14
100 / 100
126 ms3080 KiB
//#pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC target("avx,avx2,fma,sse4.2") #include<bits/stdc++.h> #define ll int #define ii __int128 #define ld long double #define cd complex<ld> #define pll pair<int,int> #define pii pair<int,int> #define pld pair<ld,ld> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ll n, k, m; ll A[200005]; bool check(ll l, ll r) { ll remain = k-(l-1)-(m-r); int i = l, j = r; vector<ll> save; ll sum = A[l]+A[r]; //cout << l << " " << r << '\n'; while(j>i&&save.size()<n&&remain>=0) { if(A[i]+A[j]==sum) { save.push_back(A[i]); save.push_back(A[j]); i++; j--; } else if(A[i]-A[l]<A[r]-A[j]) { i++; remain--; } else { j--; remain--; } } if(save.size()==n&&remain>=0) { sort(save.begin(),save.end()); for(auto u: save) { cout << u<< " "; } return 1; } return 0; } void solve() { cin >> n >> k; m = n+k; for(int i = 1; i<= m; i++) cin >> A[i]; for(int i = 1; i<= k+1; i++) { ll x = k-i+1; for(int j = m; j>= m-x; j--) { if(check(i, j)) { return; } } } } signed main() { //ios_base::sync_with_stdio(NULL) ; cin.tie(nullptr) ; cout.tie(nullptr); int t = 1;// cin >> t; //cout << -1; while(t--) { solve(); cout << "\n"; } }

Compilation message (stderr)

tabletennis.cpp: In function 'bool check(int, int)':
tabletennis.cpp:25:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     while(j>i&&save.size()<n&&remain>=0)
      |                ~~~~~~~~~~~^~
tabletennis.cpp:44:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     if(save.size()==n&&remain>=0)
      |        ~~~~~~~~~~~^~~
#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...