QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#137461 | #6626. Real Mountains | penguinman# | 0 | 0ms | 3552kb | C++17 | 1.7kb | 2023-08-10 12:56:55 | 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);
}
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;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 0ms
memory: 3496kb
input:
3 29 9 9
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
3 62 20 71
output:
7287
result:
ok 1 number(s): "7287"
Test #3:
score: -3
Wrong Answer
time: 0ms
memory: 3552kb
input:
10 72 33 22 22 13 49 53 57 72 85
output:
44479
result:
wrong answer 1st numbers differ - expected: '40403', found: '44479'
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%