Submission #400547

#TimeUsernameProblemLanguageResultExecution timeMemory
400547HazemGap (APIO16_gap)C++14
30 / 100
55 ms2276 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; #define LL long long #define F first #define S second #define pii pair<int,int> #define piii pair<pair<int,int>,int> const int M = 2e3+10; const LL INF = 1e9; const LL LINF = 1e18; const LL MOD = 1e9+7; const double PI = 3.141592653589793; long long findGap(int T, int N) { LL l1 = 0,r1 = LINF+1; LL *l = &l1,*r = &r1; LL cur = 0; vector<LL>vec; for(int i=1;i<=(N+1)/2;i++){ MinMax(l1+1,r1-1,l,r); if(*l!=*r)vec.push_back(*l),vec.push_back(*r); else vec.push_back(*r); } sort(vec.begin(),vec.end()); LL mx = 0; for(int i=0;i<vec.size()-1;i++) mx = max(mx,vec[i+1]-vec[i]); return mx; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:35:15: 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<vec.size()-1;i++)
      |              ~^~~~~~~~~~~~~
gap.cpp:22:5: warning: unused variable 'cur' [-Wunused-variable]
   22 |  LL cur = 0;
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...