Submission #167437

#TimeUsernameProblemLanguageResultExecution timeMemory
167437ThuleanxLightning Conductor (POI11_pio)C++14
81 / 100
1074 ms18992 KiB
#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); scanf("%d", &n); memset(L,0,sizeof(L)); memset(R,0,sizeof(R)); for (int i = 0; i < n; i++) scanf("%d", &h[i]); for (int i = 0; i < n; i++) { 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); for (int j = 0; i-j*j-1 >= 0; j++) R[i-j*j-1] = max(R[i-j*j-1], h[i] + j + 1); } for (int i = 1; i < n; i++) L[i] = max(L[i], L[i-1]); for (int i = n-2; i >= 0; i--) R[i] = max(R[i], R[i+1]); stringstream ss; for (int i = 0; i < n; i++) ss << max(0, max(L[i],R[i]) - h[i]) << endl; cout << ss.str(); return 0; }

Compilation message (stderr)

pio.cpp: In function 'int main()':
pio.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
pio.cpp:17: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...