Submission #751217

#TimeUsernameProblemLanguageResultExecution timeMemory
751217sofija6Gap (APIO16_gap)C++14
30 / 100
51 ms2248 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; long long findGap(int T, int N) { if (T==1) { long long l=0,r=1e18,ans=-1; vector<long long> a; while (true) { if (l>r || a.size()==N) break; long long curl,curr; MinMax(l,r,&curl,&curr); if (curl==-1) break; a.push_back(curl); if (curr!=curl) a.push_back(curr); l=curl+1; r=curr-1; } sort(a.begin(),a.end()); for (long long i=1;i<a.size();i++) ans=max(ans,a[i]-a[i-1]); return ans; } long long l,r,avg,curl,curr,ans=-1; MinMax(0,1e8,&l,&r); avg=(r-l+N-2)/(N-1); vector<long long> a; while (true) { if (l>r) break; MinMax(l,l+avg,&curl,&curr); if (curl==-1) { l+=avg+1; continue; } a.push_back(curl); if (curr!=-1) { a.push_back(curr); l=curr+avg+1; } else l+=avg+1; } for (long long i=1;i<a.size();i++) ans=max(ans,a[i]-a[i-1]); return ans; }

Compilation message (stderr)

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