답안 #872904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872904 2023-11-14T04:41:48 Z vjudge1 Climbers (RMI18_climbers) C++17
0 / 100
1 ms 2648 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 , pos = 0 , mx = 0 ;
	for(int i = 1 ; i <= n; i++){
		cin >> a[i];
		if(mx < a[i]) mx = a[i] , pos = 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]);
	}
	cout << max(p[pos] , s[pos]) << "\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();
     }
}

Compilation message

climbers.cpp: In function 'void solve()':
climbers.cpp:18:5: warning: unused variable 'ans' [-Wunused-variable]
   18 |  ll ans = 1e18 , pos = 0 , mx = 0 ;
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 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 2396 KB Output isn't correct
5 Incorrect 1 ms 2396 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Incorrect 0 ms 2396 KB Output isn't correct
3 Incorrect 0 ms 2396 KB Output isn't correct
4 Incorrect 0 ms 2396 KB Output isn't correct
5 Incorrect 1 ms 2392 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Incorrect 0 ms 2396 KB Output isn't correct
3 Incorrect 1 ms 2648 KB Output isn't correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Incorrect 1 ms 2396 KB Output isn't correct
6 Incorrect 1 ms 2396 KB Output isn't correct
7 Incorrect 1 ms 2396 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