Submission #1110782

#TimeUsernameProblemLanguageResultExecution timeMemory
1110782TitanicXDzzGap (APIO16_gap)C++14
100 / 100
52 ms4012 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; vector<long long> v; long long findGap(int T, int n) { if(T==1){ long long s=-1; long long t=(long long)1e18+1; long long x=-1; long long y=-1; long long maxi=LLONG_MIN; for(int i=1;i<=n/2;i++){ MinMax(s+1,t-1,&s,&t); v.push_back(t); v.push_back(s); } if(n%2==1){ MinMax(s+1,t-1,&s,&t); v.push_back(s); } int i=1; long long xx; sort(v.begin(),v.end()); for(auto a:v){ if(i!=1){ maxi=max(maxi,a-xx); } i++; xx=a; } return maxi; } long long s=-1; long long t=(long long)1e18+1; long long maxi=LLONG_MIN; MinMax(s+1,t-1,&s,&t); long long l=s; long long r=t; long long range=(t-s)/(n-1)+1; long long x; maxi=range-1; for(long long i=1;i<n;i++){ MinMax(l+(i-1)*range,l+i*range-1,&s,&t); if(t==-1) continue; if(i!=1){ maxi=max(maxi,s-x); } x=t; } return maxi; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:10:18: warning: unused variable 'x' [-Wunused-variable]
   10 |        long long x=-1;
      |                  ^
gap.cpp:11:18: warning: unused variable 'y' [-Wunused-variable]
   11 |        long long y=-1;
      |                  ^
gap.cpp:40:18: warning: unused variable 'r' [-Wunused-variable]
   40 |        long long r=t;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...