답안 #29537

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29537 2017-07-20T05:45:41 Z 윤교준(#1243) Lightning Conductor (POI11_pio) C++11
27 / 100
0 ms 15692 KB
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[sz(V)-2])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define rgiv(V,n) ((V)[((n)+sz(V))%sz(V)])
#define clv(V) (V).clear()
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
#define MAXN (500005)
#define MAXH (1000005)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int SQ[MAXN];

int HL[MAXH], HR[MAXH];
int H[MAXN];
int P[MAXN];
int N;

int main() {
	for(int i = 1; i <= 708; i++) {
		int s = (i-1)*(i-1) + 1, e = min(MAXN-1, i*i);
		for(int j = s; j <= e; j++) SQ[j] = i;
	}
	scanf("%d", &N);
	int mxh = -1;
	for(int i = 1; i <= N; i++) {
		scanf("%d", &H[i]);
		if(!HL[H[i]]) HL[H[i]] = i;
		HR[H[i]] = i;
		if(mxh < H[i]) mxh = H[i];
	}
	int mnh = max(0, mxh-708);
	for(int i = 1; i <= N; i++) {
		int &ret = P[i], num;
		for(int h = mnh; h <= mxh; h++) {
			if(!HL[h]) continue;
			if(HL[h] <= i) {
				num = h + SQ[i - HL[h]];
				if(ret < num) ret = num;
			}
			if(i <= HR[h]) {
				num = h + SQ[HR[h] - i];
				if(ret < num) ret = num;
			}
		}
		ret -= H[i];
	}
	for(int i = 1; i <= N; i++) printf("%d\n", P[i]);
	return 0;
}

Compilation message

pio.cpp: In function 'int main()':
pio.cpp:31:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
pio.cpp:34:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &H[i]);
                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 15692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 15692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 15692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 15692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 15692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 15692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 15692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 15692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 15692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 15692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 15692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -