제출 #703661

#제출 시각아이디문제언어결과실행 시간메모리
703661MinhAnhndGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
23 ms6976 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace std; #define ll unsigned long long using namespace __gnu_pbds; #define modu 1000000007 typedef tree<long,null_type,less<long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; //hyper_adj[a] -> b then (a before b) #define sizeofA 200002 int main(){ ios_base::sync_with_stdio(0); cin.tie(0); long N; long A[sizeofA] = {}; long xuoi1[sizeofA] = {}; long xuoi2[sizeofA] = {}; long carry1[sizeofA] = {}; long carry2[sizeofA] = {}; long val1[sizeofA]= {}; long val2[sizeofA]= {}; long lefter = 0; long walter = 0; cin>>N; ll ans = 2000000000000000000; for (long i = 1;i<=N;i++){ cin>>A[i]; xuoi1[i] = xuoi1[i-1] + max((long)0,A[i-1]+1-A[i]); } lefter = 0; for (long i = N;i>=1;i--){ xuoi2[i] = xuoi2[i+1] +max((long)0,A[i+1]+1-A[i]); } for (long i = 1;i<=N;i++){ ans = min(ans, (ll)(xuoi1[i]+xuoi2[i] - min(xuoi1[i],xuoi2[i]))); } cout<<ans; }

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

Main.cpp: In function 'int main()':
Main.cpp:28:10: warning: unused variable 'carry1' [-Wunused-variable]
   28 |     long carry1[sizeofA] = {};
      |          ^~~~~~
Main.cpp:29:10: warning: unused variable 'carry2' [-Wunused-variable]
   29 |     long carry2[sizeofA] = {};
      |          ^~~~~~
Main.cpp:30:10: warning: unused variable 'val1' [-Wunused-variable]
   30 |     long val1[sizeofA]= {};
      |          ^~~~
Main.cpp:31:10: warning: unused variable 'val2' [-Wunused-variable]
   31 |     long val2[sizeofA]= {};
      |          ^~~~
Main.cpp:32:10: warning: variable 'lefter' set but not used [-Wunused-but-set-variable]
   32 |     long lefter = 0;
      |          ^~~~~~
Main.cpp:33:10: warning: unused variable 'walter' [-Wunused-variable]
   33 |     long walter = 0;
      |          ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...