Submission #624457

#TimeUsernameProblemLanguageResultExecution timeMemory
624457socpiteGap (APIO16_gap)C++14
59.02 / 100
42 ms2328 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; #define f first #define s second typedef long long ll; ll ans = 0; int n; void solve(ll l, ll r, ll ele){ if(r-l <= ans)return; ll dist; if(ele >= 5)dist = min((r-l+ele*2)/ele*2, r-l-1); else dist = (r-l+ele)/ele; vector<pair<ll, ll>> A; for(ll i = l; i <= r; i+=dist){ pair<ll, ll> tmp; MinMax(i, min(i+dist-1, r), &tmp.f, &tmp.s); if(tmp.s > 0){ ele -= 1+(tmp.f != tmp.s); A.push_back(tmp); } } for(int i = 1; i < A.size(); i++){ if(A[i-1].f != -1 && A[i].f != -1)ans = max(ans, A[i].f - A[i-1].s); } for(auto v: A)solve(v.f, v.s, ele+1+(v.f != v.s)); } long long findGap(int T, int N) { n = N; solve(0, 1e18, N); return ans; }

Compilation message (stderr)

gap.cpp: In function 'void solve(ll, ll, ll)':
gap.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 1; i < A.size(); i++){
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...