제출 #666969

#제출 시각아이디문제언어결과실행 시간메모리
666969NursikClimbers (RMI18_climbers)C++14
0 / 100
1 ms340 KiB
#include <stdio.h> #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> //#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define f first #define s second #define ld long double const ll maxn = 5e3 + 1, maxm = 1e6 + 1; const ll mod = 1e9 + 7, inf = 1e9, block = 550, hb = 31, base = 1000050017, biginf = 5e18; const ld eps = 1e-9; int n; int a[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; int mx = 0; for (int i = 1; i <= n; ++i){ cin >> a[i]; if (a[i] > a[mx]){ mx = i; } } if (mx != 2 && mx != n - 1){ cout << "NO"; exit(0); } ll ans = 0; if (mx == 2){ for (int i = n - 1; i >= 1; --i){ ans += abs(a[i] - a[i + 1]); } } else{ for (int i = 1; i <= n - 1; ++i){ ans += abs(a[i] - a[i - 1]); } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...