Submission #278704

# Submission time Handle Problem Language Result Execution time Memory
278704 2020-08-21T16:57:24 Z arnold518 Circus (Balkan15_CIRCUS) C++14
40 / 100
4000 ms 524292 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;
const int INF = 2e9;

int N, M, P[MAXN+10];
int dist[MAXN+10];

struct Queue
{
	int u, w;
	bool operator < (const Queue &p) const { return w>p.w; }
};

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;

	fill(dist+1, dist+N+2, INF);
	priority_queue<Queue> PQ;
	PQ.push({N+1, 0});
	while(!PQ.empty())
	{
		Queue now=PQ.top(); PQ.pop();
		if(dist[now.u]<=now.w) continue;
		dist[now.u]=now.w;
		for(int i=1; i<=N; i++)
		{
			if(abs(P[i]-P[now.u])>=now.w) PQ.push({i, abs(P[i]-P[now.u])});
		}
	}
}

int minLength(int D)
{
	int ans=2e9;
	for(int i=1; i<=N+1; i++) if(dist[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 Runtime error 876 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 1217 ms 33340 KB Output is correct
6 Correct 1113 ms 33340 KB Output is correct
7 Correct 1475 ms 33340 KB Output is correct
8 Correct 1504 ms 33364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 1217 ms 33340 KB Output is correct
6 Correct 1113 ms 33340 KB Output is correct
7 Correct 1475 ms 33340 KB Output is correct
8 Correct 1504 ms 33364 KB Output is correct
9 Execution timed out 4073 ms 33468 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 876 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 876 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -