QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137478 | #6626. Real Mountains | penguinman# | 0 | 1ms | 3596kb | C++17 | 1.7kb | 2023-08-10 13:12:15 | 2024-07-04 01:29:16 |
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];
vi goal(N,inf);
ll max = 0;
rep(i,0,N){
max = std::max(max, H[i]);
goal[i] = std::min(goal[i], max);
}
max = 0;
per(i,N-1,0){
max = std::max(max, H[i]);
goal[i] = std::min(goal[i], max);
}
rep(i,0,N) cout << goal[i] << " ";
cout << ln;
ll ans = 0;
rep(i,0,N){
ans += (goal[i]-1+H[i])*(goal[i]-H[i])/2;
ans %= mod;
}
std::set<ll> set;
rep(i,0,N){
set.insert(H[i]);
ll now = H[i];
for(auto el: set){
if(el >= now){
ans += (std::min(el, goal[i])-now)*el;
ans %= mod;
now = std::min(el, goal[i]);
}
}
}
set.clear();
per(i,N-1,0){
set.insert(H[i]);
ll now = H[i];
for(auto el: set){
if(el >= now){
ans += (std::min(el, goal[i])-now)*el;
ans %= mod;
now = std::min(el, goal[i]);
}
}
}
cout << ans << ln;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3596kb
input:
3 29 9 9
output:
29 9 9 0
result:
wrong answer 1st numbers differ - expected: '0', found: '29'
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%