제출 #426476

#제출 시각아이디문제언어결과실행 시간메모리
426476juggernautGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
43 ms8484 KiB
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} typedef long long ll; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef IOI2021SG #define printl(args...)printf(args) #else #define printl(args...)((void)0) #endif int n; ll a[200005]; ll b[200005]; ll pref[200005]; ll suff[200005]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%lld",&a[i]),b[i]=a[i]; for(int i=2;i<=n;i++){ b[i]+=suff[i-1]; ll pivot=max(0ll,b[i-1]-b[i]+1); suff[i]=suff[i-1]+pivot; b[i]+=pivot; } for(int i=1;i<=n;i++)b[i]=a[n-i+1]; for(int i=2;i<=n;i++){ b[i]+=pref[i-1]; ll pivot=max(0ll,b[i-1]-b[i]+1); pref[i]=pref[i-1]+pivot; b[i]+=pivot; } reverse(pref+1,pref+1+n); ll mn=9e18; for(int i=1;i<=n;i++)umin(mn,max(pref[i],suff[i])); printf("%lld",mn); }

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

Main.cpp: In function 'void usaco(std::string)':
Main.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
Main.cpp:27:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     for(int i=1;i<=n;i++)scanf("%lld",&a[i]),b[i]=a[i];
      |                          ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...