QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137492 | #6626. Real Mountains | penguinman# | 0 | 0ms | 3648kb | C++17 | 1.4kb | 2023-08-10 13:26:21 | 2024-07-04 02:35:42 |
Judging History
answer
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define pb emplace_back
#define mp std::make_pair
#define all(a) a.begin(),a.end()
#define mtp std::make_tuple
constexpr ll inf = (1ll<<60);
constexpr ll mod = (1e6)+3;
int main(){
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
ll N; cin >> N;
vi H(N);
rep(i,0,N) cin >> H[i];
ll ans = 0;
vector<bool> flag(N,1);
while(true){
ll min = inf;
rep(i,0,N){
if(flag[i]) min = std::min(min, H[i]);
}
if(min == inf) break;
rep(i,0,N){
if(!flag[i] || min != H[i]) continue;
ll l = inf, r = inf;
rep(j,0,i){
if(H[j] > H[i]) l = std::min(l, H[j]);
}
rep(j,i+1,N){
if(H[j] > H[i]) r = std::min(r, H[j]);
}
if(l == inf || r == inf){
flag[i] = false;
}
else{
ans += l+r+H[i];
H[i]++;
}
break;
}
}
cout << ans << ln;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 0ms
memory: 3648kb
input:
3 29 9 9
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
3 62 20 71
output:
7287
result:
ok 1 number(s): "7287"
Test #3:
score: -3
Wrong Answer
time: 0ms
memory: 3548kb
input:
10 72 33 22 22 13 49 53 57 72 85
output:
41617
result:
wrong answer 1st numbers differ - expected: '40403', found: '41617'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #3:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%