제출 #914178

#제출 시각아이디문제언어결과실행 시간메모리
914178LitusianoAirplane (NOI23_airplane)C++17
0 / 100
39 ms6996 KiB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma") #include<bits/stdc++.h> using namespace std; #define int long long int n,m; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m; vector<vector<int>> G; vector<int> v(n); for(int& i : v) cin>>i; int trash; while(m--) cin>>trash>>trash; vector<int> suf(n+1); suf[n] = 0; for(int i = n-1; i>=0 ; i--) suf[i] = max(v[i], suf[i+1]); int h = 0; int ans = 0; for(int i = 0; i<n; i++){ if(v[i] > h){ ans += v[i]-h; h = v[i]; // just go up } else if(h < suf[i]) h++; else if(h > suf[i]) h--; } // cout<<ans<<" "; cout<<ans+n-1+h<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...