Submission #278695

# Submission time Handle Problem Language Result Execution time Memory
278695 2020-08-21T16:45:17 Z arnold518 Circus (Balkan15_CIRCUS) C++14
0 / 100
4000 ms 2192 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];
int dp[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+1]=M;

	dp[N+1]=0;
	for(int i=N; i>=1; i--)
	{
		dp[i]=2e9;
		for(int j=i+1; j<=N+1; j++)
		{
			if(dp[j]<=P[j]-P[i]) dp[i]=min(dp[i], P[j]-P[i]);
		}
	}
}


int minLength(int D)
{
	int ans=2e9;
	for(int i=1; i<=N+1; i++) if(dp[i]<=abs(P[i]-D)) ans=min(ans, abs(P[i]-D));
	return ans;
}

Compilation message

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 Execution timed out 4048 ms 2192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4048 ms 2192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4048 ms 2192 KB Time limit exceeded
2 Halted 0 ms 0 KB -