제출 #447649

#제출 시각아이디문제언어결과실행 시간메모리
447649cpp219Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
127 ms7072 KiB
#pragma GCC optimization O2 #pragma GCC optimization "unroll-loop" #pragma target ("avx2") #include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 2e5 + 9; const ll Log2 = 21; const ll inf = 1e16 + 7; ll n,a[N],prvL[N],prvR[N]; bool chk(ll m){ ll L = 1,R = n; for (ll i = 2;i <= n;i++){ ll prv = a[i - 1] + prvL[i - 1]; prvL[i] = max(prvL[i - 1],max(0ll,prv - a[i] + 1)); if (prvL[i] > m) break; L = i; } for (ll i = n - 1;i > 0;i--){ ll prv = a[i + 1] + prvR[i + 1]; prvR[i] = max(prvR[i + 1],max(0ll,prv - a[i] + 1)); if (prvR[i] > m) break; R = i; } return (R <= L); } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n; for (ll i = 1;i <= n;i++) cin>>a[i]; ll l,m,h; l = 0;h = inf; while(l <= h){ m = (l + h)/2; if (chk(m)) h = m - 1; else l = m + 1; } cout<<l; }

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

Main.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization O2
      | 
Main.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
Main.cpp:3: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    3 | #pragma target ("avx2")
      | 
Main.cpp: In function 'bool chk(long long int)':
Main.cpp:23:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   23 |         if (prvL[i] > m) break; L = i;
      |         ^~
Main.cpp:23:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   23 |         if (prvL[i] > m) break; L = i;
      |                                 ^
Main.cpp:28:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |         if (prvR[i] > m) break; R = i;
      |         ^~
Main.cpp:28:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   28 |         if (prvR[i] > m) break; R = i;
      |                                 ^
Main.cpp: In function 'int main()':
Main.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...