제출 #534808

#제출 시각아이디문제언어결과실행 시간메모리
534808Paul_Liao_1457Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
0 / 100
0 ms332 KiB
// 還要更強 #include<iostream> #include<queue> #include<set> #include<map> #include<iomanip> #include<math.h> #include<cstring> #include<stack> #include<string.h> #include<random> #include<algorithm> #include<vector> #define ll long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define REP(i,a,b) for(int i=a;i>=b;i--) #define INF (ll)(4e18) #define pb push_back #define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; ll b[200005],a[200005],pre[200005],suf[200005]; vector<ll> r,l; signed main(){ AC; bool ok=1; int n; cin>>n; FOR(i,1,n+1) cin>>a[i]; FOR(i,1,n+1){ b[i]=a[i]-a[i-1]; if(b[i]>=0) r.pb(i); else l.pb(i); if(b[i]==0) ok=0; } FOR(i,1,n+1){ pre[i]=pre[i-1]; if(b[i]<=0) pre[i]+=(1-b[i]); } REP(i,n,1){ suf[i]=suf[i+1]; if(b[i]>=0) suf[i]+=(b[i]+1); } ll ans=INF; FOR(i,1,n+2){ if(pre[i-1]>=suf[i]){ ans=min(ans,pre[i-1]); } } cout<<ans<<endl; }

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

Main.cpp: In function 'int main()':
Main.cpp:29:10: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   29 |     bool ok=1;
      |          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...