제출 #158540

#제출 시각아이디문제언어결과실행 시간메모리
158540luciocfLightning Conductor (POI11_pio)C++14
100 / 100
159 ms11192 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5+10; int n; int h[maxn]; int L[maxn], R[maxn]; void get_candidates(void) { int last = -1; for (int i = 1; i <= n; i++) { if (h[i] <= last) continue; last = h[i]; for (int d = 1; i + (d-1)*(d-1) + 1 <= n; d++) { int p = i + (d-1)*(d-1) + 1; L[p] = max(L[p], h[i]+d); } } last = -1; for (int i = n; i >= 1; i--) { if (h[i] <= last) continue; last = h[i]; for (int d = 1; i - (d-1)*(d-1) - 1 > 0; d++) { int p = i - (d-1)*(d-1) - 1; R[p] = max(R[p], h[i]+d); } } } int main(void) { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &h[i]); get_candidates(); for (int i = 1; i <= n; i++) L[i] = max(L[i-1], L[i]); for (int i = n; i >= 1; i--) R[i] = max(R[i+1], R[i]); for (int i = 1; i <= n; i++) printf("%d\n", max(0, max(R[i], L[i])-h[i])); }

컴파일 시 표준 에러 (stderr) 메시지

pio.cpp: In function 'int main()':
pio.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
pio.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &h[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...