Submission #364257

#TimeUsernameProblemLanguageResultExecution timeMemory
364257_martynasSwimming competition (LMIO18_plaukimo_varzybos)C++11
100 / 100
513 ms13036 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back const ll INF = 1e13; const int MAX_N = 1e6+5; int N, A, B; int T[MAX_N]; bool check_t(int c_t) { deque<int> I; I.pb(-1); int i = 0; while(i < N && !I.empty()) { int curr_i = I.front(); if(i - curr_i >= A) { if(i - curr_i <= B && T[i] - T[curr_i + 1] <= c_t) { I.pb(i); i++; } else { I.pop_front(); } } else { i++; } } return !I.empty() && I.back() == N-1; } int bin_search() { int l = 0, r = T[N-1]; int mid; while(l < r) { mid = l + (r-l) / 2; bool can = check_t(mid); if(can) { r = mid; } else { l = mid+1; } } return l; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); scanf("%d%d%d", &N, &A, &B); for(int i = 0; i < N; i++) { scanf("%d", &T[i]); } sort(T, T + N); int ans = bin_search(); cout << ans << endl; return 0; }

Compilation message (stderr)

plaukimo_varzybos.cpp: In function 'int main()':
plaukimo_varzybos.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   72 |     scanf("%d%d%d", &N, &A, &B);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
plaukimo_varzybos.cpp:76:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   76 |         scanf("%d", &T[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...