Submission #691800

#TimeUsernameProblemLanguageResultExecution timeMemory
691800LextyleTable Tennis (info1cup20_tabletennis)C++17
87 / 100
246 ms10888 KiB
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma warning(disable : 6031) #define USACO freopen("moocast.in", "r", stdin); freopen("moocast.out", "w+", stdout) #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define ll long long using namespace std; ll binpow(ll a, ll x, ll m) { ll ans = 1, md = a % m; for (int i = 0; i < 63; i++) { if (x & ((ll)1 << i)) ans = (ans * md) % m; md = (md * md) % m; } return ans; } vector<ll> gcd(ll a, ll b) { if (b == 0) { return { a, 1, 0 }; } vector<ll> d = gcd(b, a % b); return { d[0], d[2], d[1] - d[2] * (a / b) }; } ll lcm(ll a, ll b) { return a * b / gcd(a, b)[0]; } int a[200000]; void solve() { int n, k; cin >> k >> n; n += k; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { for (int j = i + k - 1; j < n; j++) { set<int> ans; ans.insert(a[i]); ans.insert(a[j]); for (int l = i + 1, r = j - 1; ans.size() < k; l++) { while (r > l && a[j] - a[r] < a[l] - a[i]) r--; if (r == l) break; if (a[j] - a[r] == a[l] - a[i]) { ans.insert(a[l]); ans.insert(a[r]); r--; } } if (ans.size() == k) { for (auto c : ans) cout << c << " "; return; } } } } int main() { //USACO; fastIO; solve(); }

Compilation message (stderr)

tabletennis.cpp:2: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    2 | #pragma warning(disable : 4996)
      | 
tabletennis.cpp:3: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    3 | #pragma warning(disable : 6031)
      | 
tabletennis.cpp: In function 'void solve()':
tabletennis.cpp:41:46: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |    for (int l = i + 1, r = j - 1; ans.size() < k; l++) {
      |                                   ~~~~~~~~~~~^~~
tabletennis.cpp:50:19: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |    if (ans.size() == k) {
      |        ~~~~~~~~~~~^~~~
#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...