Submission #278634

#TimeUsernameProblemLanguageResultExecution timeMemory
278634arnold518Circus (Balkan15_CIRCUS)C++14
0 / 100
27 ms1144 KiB
#include "circus.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, M, P[MAXN+10]; void init(int _N, int _M, int _P[]) { N=_N; M=_M; for(int i=1; i<=N; i++) P[i]=_P[i-1]; sort(P+1, P+N+1); N=unique(P+1, P+N+1)-P; P[++N]=M; } bool solve(int x) { for(int i=0; i<N;) { int j; for(j=i; j<=N && P[j]-P[i]<=x; j++); if(i==j-1) return false; x=P[j-1]-P[i]; i=j-1; //printf("%d ", i); } return true; } int minLength(int D) { int lo=0, hi=1e9; while(lo+1<hi) { int mid=lo+hi>>1; if(solve(mid)) hi=mid; else lo=mid; //printf(" : %d\n", mid); } return hi; }

Compilation message (stderr)

circus.cpp: In function 'int minLength(int)':
circus.cpp:40:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |   int mid=lo+hi>>1;
      |           ~~^~~
grader.cpp: In function 'int main()':
grader.cpp:14:12: warning: unused variable 'max_code' [-Wunused-variable]
   14 |  long long max_code;
      |            ^~~~~~~~
grader.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  scanf("%d%d", &N, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~
grader.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |   scanf("%d", &P[i]);
      |   ~~~~~^~~~~~~~~~~~~
grader.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  scanf("%d", &Q);
      |  ~~~~~^~~~~~~~~~
grader.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |   scanf("%d", &d);
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...