QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#113735 | #6626. Real Mountains | 1kri# | 0 | 1ms | 5768kb | C++14 | 1.3kb | 2023-06-19 09:19:53 | 2024-06-04 09:56:10 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#define ll long long
#define inf 2000000000
#define mod 1000003
using namespace std;
int n,h[1000005];
int p,_h[1000005];
int qwq[1000005];
ll ans;
int gs(int l,int r){
return 1ll*(l+r)*(r-l+1)/2%mod;
}
int main(){
cin>>n;
for (int i=1;i<=n;i++)scanf("%d",&h[i]);
for (int i=1;i<=n;i++)
if (p==0||h[i]>h[p])p=i;
for (int i=1;i<=p;i++)_h[i]=max(h[i],_h[i-1]);
for (int i=n;i>=p;i--)_h[i]=max(h[i],_h[i+1]);
for (int i=1;i<=n;i++)qwq[i]=h[i];
sort(qwq+1,qwq+1+n);
for (int t=1;t<n;t++){
if (qwq[t]==qwq[t+1])continue;
int mn=qwq[t],nxt=qwq[t+1],l=-1,r=-1,cnt=0;
for (int i=1;i<=n;i++)
if (h[i]!=_h[i]&&h[i]==mn){
if (l==-1)l=i;
r=i;
cnt++;
}
if (cnt==0)continue;
int vl=inf,vr=inf,xl=inf,xr=inf;
for (int i=1;i<l;i++)
if (h[i]>mn)vl=min(vl,h[i]);
for (int i=l+1;i<=n;i++)
if (h[i]>mn)xl=min(xl,h[i]);
for (int i=n;i>r;i--)
if (h[i]>mn)vr=min(vr,h[i]);
for (int i=r-1;i>=1;i--)
if (h[i]>mn)xr=min(xr,h[i]);
if (l==r){
ans=(ans+gs(mn,nxt-1)+vl+vr)%mod;
h[l]=nxt;
continue;
}
ans=(ans+vl+vr+min(xl,xr)+1+2ll*(cnt-2)+1ll*(cnt+1)*gs(mn,nxt-1))%mod;
for (int i=1;i<=n;i++)
if (h[i]!=_h[i]&&h[i]==mn)h[i]=nxt;
}
cout<<ans<<endl;
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 1ms
memory: 5720kb
input:
3 29 9 9
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: -3
Wrong Answer
time: 0ms
memory: 5768kb
input:
3 62 20 71
output:
1834
result:
wrong answer 1st numbers differ - expected: '7287', found: '1834'
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%