Submission #81839

# Submission time Handle Problem Language Result Execution time Memory
81839 2018-10-27T06:53:51 Z tmwilliamlin168 Lightning Conductor (POI11_pio) C++14
72 / 100
1000 ms 9436 KB
#include <bits/stdc++.h>
using namespace std;

inline int in() {
	int r=0;
	char ch=getchar_unlocked();
	while(1) {
		if(ch>='0'&&ch<='9')
			break;
		ch=getchar_unlocked();
	}
	r=ch-'0';
	while(1) {
		ch=getchar_unlocked();
		if (ch<'0'||ch>'9')
			break;
		r=r*10+ch-'0';
	}
	return r;
}
inline void out(int x) {
	if(!x) {
		putchar_unlocked('0');
		return;
	}
	int r=x, c=0;
	while(!(r%10)) {
		++c;
		r/=10;
	}
	r=0;
	while(x) {
		r=r*10+x%10;
		x/=10;
	}
	while(r) {
		putchar_unlocked(r%10+'0');
		r/=10;
	}
	while(c--)
		putchar_unlocked('0');
}

const int mxN=5e5;
int n, h[mxN], a[mxN], a1[mxN+1], a2[mxN+1];

int main() {
	n=in();
	for(int i=0; i<n; ++i) {
		a1[i+1]=max(a[i]=h[i]=in(), a1[i]);
		for(int j=0; i-j*j-1>=0; ++j)
			a1[i+1]=max(++a[i-j*j-1], a1[i+1]);
	}
	for(int i=n-1; i>=0; --i) {
		a2[i]=max(a[i]=h[i], a2[i+1]);
		for(int j=0; i+j*j+1<=n-1; ++j)
			a2[i]=max(++a[i+j*j+1], a2[i]);
	}
	for(int i=0; i<n; ++i) {
		out(max(a1[i+1], a2[i])-h[i]);
		putchar_unlocked('\n');
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1740 KB Output is correct
2 Correct 45 ms 1740 KB Output is correct
3 Correct 48 ms 2184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 2476 KB Output is correct
2 Correct 88 ms 2488 KB Output is correct
3 Correct 95 ms 3032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 332 ms 5328 KB Output is correct
2 Correct 332 ms 5328 KB Output is correct
3 Correct 332 ms 5716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 687 ms 9436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 9436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 9436 KB Time limit exceeded
2 Halted 0 ms 0 KB -