Submission #275816

# Submission time Handle Problem Language Result Execution time Memory
275816 2020-08-20T07:52:47 Z 송준혁(#5101) Circus (Balkan15_CIRCUS) C++17
40 / 100
4000 ms 524292 KB
#include "circus.h"
#include <bits/stdc++.h>
#define INF 1'000'000'007
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int N, ans;
int A[101010];
int D[101010];
priority_queue<pii> PQ;

void init(int _N, int M, int P[]){
	N = _N;
	for (int i=0; i<N; i++) A[i] = P[i];
	A[N] = M;
	for (int i=0; i<=N; i++) D[i] = INF;
	PQ.push(pii(0, N));
	while (PQ.size()){
		int u, d;
		tie(d, u) = PQ.top();
		PQ.pop();
		if (D[u] != INF) continue;
		D[u] = -d;
		for (int i=0; i<N; i++){
			if (D[i] == INF && abs(A[i]-A[u])>=-d) PQ.push(pii(-abs(A[i]-A[u]), i));
		}
	}
}

int minLength(int x) {
	ans = INF;
	for (int i=0; i<=N; i++) if (abs(A[i]-x) >= D[i]) ans = min(ans, abs(A[i]-x));
	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 1386 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 580 ms 16852 KB Output is correct
6 Correct 605 ms 16888 KB Output is correct
7 Correct 547 ms 16856 KB Output is correct
8 Correct 618 ms 16856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 580 ms 16852 KB Output is correct
6 Correct 605 ms 16888 KB Output is correct
7 Correct 547 ms 16856 KB Output is correct
8 Correct 618 ms 16856 KB Output is correct
9 Execution timed out 4014 ms 21932 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1386 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1386 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -