Submission #278641

# Submission time Handle Problem Language Result Execution time Memory
278641 2020-08-21T15:58:51 Z arnold518 Circus (Balkan15_CIRCUS) C++14
0 / 100
26 ms 1152 KB
#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-1;
	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

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 time Memory Grader output
1 Incorrect 26 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -