Submission #679203

#TimeUsernameProblemLanguageResultExecution timeMemory
679203tigarGap (APIO16_gap)C++14
100 / 100
54 ms3228 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; typedef long long ll; ll mn, mx, niz[100010]; vector<ll>niz2; /*int T, N; ll call_count, subtask_num, A[100000]; static void my_assert(int k){ if (!k) exit(1); } void MinMax(long long s, long long t, long long *mn, long long *mx) { int lo = 1, hi = N, left = N+1, right = 0; my_assert(s <= t && mn != NULL && mx != NULL); while (lo <= hi){ int mid = (lo+hi)>>1; if (A[mid] >= s) hi = mid - 1, left = mid; else lo = mid + 1; } lo = 1, hi = N; while (lo <= hi){ int mid = (lo+hi)>>1; if (A[mid] <= t) lo = mid + 1, right = mid; else hi = mid - 1; } if (left > right) *mn = *mx = -1; else{ *mn = A[left]; *mx = A[right]; } if (subtask_num == 1) call_count++; else if (subtask_num == 2) call_count += right-left+2; } */ ll findGap(int T, int N) { if(T==1) { int begg=0, endd=N-1; ll low_bound=0, up_bound=LONG_LONG_MAX; while(begg<=endd) { MinMax(low_bound, up_bound, &mn, &mx); niz[begg]=mn; niz[endd]=mx; //cout<<mn<<" "<<mx<<endl; begg++; endd--; low_bound=mn+1; up_bound=mx-1; } ll razlika=0; for(int i=0; i<N; i++) {razlika=max(razlika, niz[i+1]-niz[i]);} return razlika; } else { MinMax(0, LONG_LONG_MAX, &mn, &mx); ll prosek=(mx-mn)/(N-1); ll pocetak=mn, kraj=mx; while(pocetak<kraj) { MinMax(pocetak, pocetak+prosek, &mn, &mx); if(mn!=-1)niz2.push_back(mn); if(mx!=-1)niz2.push_back(mx); pocetak=pocetak+prosek+1; } ll razlika=0; for(int i=0; i<niz2.size()-1; i++)razlika=max(razlika,niz2[i+1]-niz2[i]); return razlika; } } /*int main() { cin>>T>>N; for(int i=1; i<=N; i++)cin>>A[i]; cout<<findGap(T, N); } /*1 2 1 3 4!!!!*/

Compilation message (stderr)

gap.cpp:82:1: warning: "/*" within comment [-Wcomment]
   82 | /*1 2
      |  
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:71:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |         for(int i=0; i<niz2.size()-1; i++)razlika=max(razlika,niz2[i+1]-niz2[i]);
      |                      ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...