Submission #683934

#TimeUsernameProblemLanguageResultExecution timeMemory
683934abcdehelloGap (APIO16_gap)C++17
70 / 100
56 ms3268 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll findGap(int T, int N) { ll mn,mx; MinMax(0,1LL<<60,&mn,&mx); vector<ll> a(0); ll ans=-1; if (T==1){ a.push_back(mn);a.push_back(mx); while (mn<mx){ MinMax(mn+1,mx-1,&mn,&mx); if (mn!=-1) a.push_back(mn); if (mx!=-1) a.push_back(mx); } } else{ ll gmn=mn,gmx=mx,rng=(mx-mn+N-2)/(N-1)+1; a.push_back(mn);a.push_back(mx); gmn++; while (gmn<gmx){ MinMax(gmn,gmn+rng,&mn,&mx); if (mn!=-1) a.push_back(mn); if (mx!=-1) a.push_back(mx); gmn+=rng; } } sort(a.begin(),a.end()); for (int i=1;i<a.size();i++){ ans=max(ans,a[i]-a[i-1]); } return ans; return 0; }

Compilation message (stderr)

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