Submission #1001846

#TimeUsernameProblemLanguageResultExecution timeMemory
1001846daffuwuTable Tennis (info1cup20_tabletennis)C++14
20 / 100
36 ms6848 KiB
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); long long n, k, a[156069]; vector<long long> ans, cur; vector<long long> slv(long long sm) { long long i, l, r; vector<long long> ret; for (l=1, r=n+k; l<r; l++, r--) { for (; l<r && a[l]+a[r]!=sm; ) { if (a[l]+a[r]>sm) r--; else l++; } if (l == r) break; ret.push_back(l); ret.push_back(r); } sort(ret.begin(), ret.end()); long long sz = ret.size(); long long m = (sz-n)/2; //hapus m kiri dan m kanan reverse(ret.begin(), ret.end()); for (i=1; i<=m; i++) ret.pop_back(); reverse(ret.begin(), ret.end()); for (i=1; i<=m; i++) ret.pop_back(); return ret; } int main() { long long i, j; scanf("%lld%lld", &n, &k); for (i=1; i<=n+k; i++) { scanf("%lld", a+i); } pair<long long, long long> op[] = {{1, n+k}, {2, n+k}, {1, n+k-1}, {2, n+k-1}}; for (i=0; i<=3; i++) { auto [l, r] = op[i]; if (l<r) { cur = slv(a[l]+a[r]); if (cur.size() == n) ans = cur; } } for (auto x:ans) printf("%lld ", a[x]); printf("\n"); }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:47:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   47 |         auto [l, r] = op[i];
      |              ^
tabletennis.cpp:51:28: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   51 |             if (cur.size() == n) ans = cur;
      |                 ~~~~~~~~~~~^~~~
tabletennis.cpp:38:18: warning: unused variable 'j' [-Wunused-variable]
   38 |     long long i, j;
      |                  ^
tabletennis.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%lld%lld", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
tabletennis.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf("%lld", a+i);
      |         ~~~~~^~~~~~~~~~~~~
#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...