제출 #1294068

#제출 시각아이디문제언어결과실행 시간메모리
1294068thuhienne새로운 문제 (POI11_pio)C++20
63 / 100
1098 ms42640 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define re exit(0); #define thuhien "" int n,h[500009]; namespace sub1 { bool check() { return n <= 5000; } void solve() { for (int i = 1;i <= n;i++) { int res = 0; for (int j = 1;j <= n;j++) { res = max(res,h[j] - h[i] + (int)ceil( sqrt( abs(i - j) ) )); } cout << res << '\n'; } } } namespace sub2 { bool check() { return n <= 200000; } const int LOG = 19; int sparse[500009][LOG + 1]; int getmax(int l,int r) { l = max(l,1),r = min(r,n); if (l > r) return -1e9; int i = __lg(r - l + 1); return max(sparse[l][i],sparse[r - (1 << i) + 1][i]); } void solve() { for (int i = 1;i <= n;i++) sparse[i][0] = h[i]; for (int j = 1;j <= LOG;j++) { for (int i = 1;i + (1 << j) - 1 <= n;i++) { sparse[i][j] = max(sparse[i][j - 1],sparse[i + (1 << (j - 1))][j - 1]); } } for (int i = 1;i <= n;i++) { int res = 0; for (int can = 1;(can - 1) * (can - 1) <= n;can++) { int l = (can - 1) * (can - 1) + 1,r = can * can; res = max(res,max(getmax(i - r,i - l),getmax(i + l,i + r)) - h[i] + can); } cout << res << '\n'; } } } int main() { ios_base::sync_with_stdio(0);cin.tie(nullptr); if (fopen(thuhien".inp","r")) { freopen(thuhien".inp","r",stdin); freopen(thuhien".out","w",stdout); } cin >> n; for (int i = 1;i <= n;i++) cin >> h[i]; if (sub1::check()) { sub1::solve(); return 0; } // if (sub2::check()) { sub2::solve(); return 0; // } }

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

pio.cpp: In function 'int main()':
pio.cpp:64:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |                 freopen(thuhien".inp","r",stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
pio.cpp:65:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |                 freopen(thuhien".out","w",stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...