이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |