답안 #872903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872903 2023-11-14T04:38:50 Z vjudge1 Climbers (RMI18_climbers) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
#define f first
#define S second
#define pb push_back
#define msk(x , y) ((x >> y) & 1)
#define all(x) x.begin() , x.end()
using namespace std;
typedef long long int ll;
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
const int dx[] = {-1,-1,1,1,2,-2,2,-2};
const int dy[] = {-2,2,2,-2,1,1,-1,-1};

ll n , a[N] , p[N] , s[N];

void solve(){
	cin >> n ;
	ll ans = 1e18;
	for(int i = 1 ; i <= n; i++){
		cin >> a[i];
	}
	for(int i = 1 ; i <= n ; i++){
		p[i] = p[i - 1] + abs(a[i] - a[i - 1]);
	}
	for(int i = n ; i >= 1 ; i--){
		s[i] = s[i + 1] + abs(a[i] - a[i + 1]);
	}
	for(int i = 1 ; i <= n ; i++){
		ans = min(ans , max(s[i] , p[i]));
	}
	cout << ans << "\n";
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);  
    cout.tie(0);
    int test=1;
    // cin >> test ;
    for(int i=1;i<=test;i++){
//      cout << "Case " << i << ": ";
        solve();
     }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Incorrect 1 ms 2392 KB Output isn't correct
5 Incorrect 1 ms 2392 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Incorrect 0 ms 2396 KB Output isn't correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Incorrect 0 ms 2396 KB Output isn't correct
5 Incorrect 1 ms 2396 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Incorrect 1 ms 2392 KB Output isn't correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Incorrect 1 ms 2392 KB Output isn't correct
6 Incorrect 1 ms 2392 KB Output isn't correct
7 Incorrect 1 ms 2392 KB Output isn't correct
8 Incorrect 1 ms 2396 KB Output isn't correct
9 Incorrect 1 ms 2396 KB Output isn't correct
10 Incorrect 1 ms 2396 KB Output isn't correct