제출 #408911

#제출 시각아이디문제언어결과실행 시간메모리
408911mat_vGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
35 ms8652 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) #define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i)) #define mod 998244353 #define xx first #define yy second #define all(a) (a).begin(), (a).end() #define pb push_back #define ll long long #define pii pair<int,int> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less) mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int n; ll niz[200005]; ll diff[200005]; ll pref[200005]; ll suff[200005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; ff(i,1,n)cin >> niz[i]; ff(i,1,n - 1)diff[i] = niz[i + 1] - niz[i]; n--; ff(i,1,n){ pref[i] += pref[i - 1]; if(diff[i] <= 0)pref[i] += (1LL-diff[i]); } fb(i,n,1){ suff[i] += suff[i+1]; if(diff[i] >= 0)suff[i] += (diff[i]+1LL); } ll ans = suff[1]; ff(i,1,n)ans = min(ans, max(suff[i],pref[i - 1])); ans = min(ans, pref[n]); cout << ans << "\n"; return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
Main.cpp:35:5: note: in expansion of macro 'ff'
   35 |     ff(i,1,n)cin >> niz[i];
      |     ^~
Main.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
Main.cpp:36:5: note: in expansion of macro 'ff'
   36 |     ff(i,1,n - 1)diff[i] = niz[i + 1] - niz[i];
      |     ^~
Main.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
Main.cpp:39:5: note: in expansion of macro 'ff'
   39 |     ff(i,1,n){
      |     ^~
Main.cpp:7:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
      |                           ^
Main.cpp:43:5: note: in expansion of macro 'fb'
   43 |     fb(i,n,1){
      |     ^~
Main.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
Main.cpp:49:5: note: in expansion of macro 'ff'
   49 |     ff(i,1,n)ans = min(ans, max(suff[i],pref[i - 1]));
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...