Submission #167433

# Submission time Handle Problem Language Result Execution time Memory
167433 2019-12-08T14:45:16 Z Thuleanx Lightning Conductor (POI11_pio) C++14
81 / 100
1000 ms 19396 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 5e5+7;
int n;
int h[N];
int L[N], R[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	memset(L,0,sizeof(L));
	memset(R,0,sizeof(R));
	for (int i = 0; i < n; i++)
		cin>>h[i];
	for (int i = 0; i < n; i++) {
		if (i) L[i] = max(L[i], L[i-1]);
		for (int j = 0; i+j*j+1 < n; j++) 
			L[i+j*j+1] = max(L[i+j*j+1], h[i] + j + 1);
	}
	reverse(h, h+n);
	for (int i = 0; i < n; i++) {
		if (i) R[i] = max(R[i], R[i-1]);
		for (int j = 0; i+j*j+1 < n; j++) 
			R[i+j*j+1] = max(R[i+j*j+1], h[i] + j + 1);
	}
	reverse(h, h+n);
	stringstream ss;
	for (int i = 0; i < n; i++)
		ss << max(0, max(L[i], R[n-1-i]) - h[i]) << endl;
	cout << ss.str();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 5748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 6516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 6204 KB Output is correct
2 Correct 49 ms 5624 KB Output is correct
3 Correct 53 ms 6644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 7052 KB Output is correct
2 Correct 97 ms 6900 KB Output is correct
3 Correct 98 ms 8292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 336 ms 10724 KB Output is correct
2 Correct 330 ms 9968 KB Output is correct
3 Correct 333 ms 11496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 659 ms 19396 KB Output is correct
2 Correct 634 ms 13420 KB Output is correct
3 Correct 640 ms 18248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 11000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 11124 KB Time limit exceeded
2 Halted 0 ms 0 KB -