Submission #535491

#TimeUsernameProblemLanguageResultExecution timeMemory
535491byunjaewooGap (APIO16_gap)C++17
30 / 100
65 ms2784 KiB
#include <bits/stdc++.h> using namespace std; using ll=long long; #include "gap.h" ll findGap(int T, int N) { if(T==1) { ll res=0, s=-1, e=(ll)1e18+1; vector<ll> V; for(int i=1; i<=(N+1)/2; i++) { MinMax(s+1, e-1, &s, &e); V.push_back(s); if(s!=e) V.push_back(e); } sort(V.begin(), V.end()); for(int i=0; i<V.size()-1; i++) res=max(res, V[i+1]-V[i]); return res; } ll s, e, res=0; MinMax(0, (ll)1e18, &s, &e); res=e-s; s++, e--; vector<ll> a, b; for(ll i=1; i<=N+1; i++) { ll l=s+((e-s)/N*(i-1)), r=min(e, s+((e-s)/N*i)-1); if(l>r) continue; ll x, y; MinMax(l, r, &x, &y); if(x!=-1) { a.push_back(x); b.push_back(y); } } if(a.size()) res=max(a[0]-s+1, e-b.back()+1); for(int i=0; i<a.size()-1; i++) res=max(res, a[i+1]-b[i]); return res; }

Compilation message (stderr)

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(int i=0; i<V.size()-1; i++) res=max(res, V[i+1]-V[i]);
      |                      ~^~~~~~~~~~~
gap.cpp:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i=0; i<a.size()-1; i++) res=max(res, a[i+1]-b[i]);
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...