QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#502252 | #323. Hills | YassirSalama | 0 | 0ms | 3808kb | C++14 | 1.0kb | 2024-08-03 02:01:46 | 2024-08-03 02:01:47 |
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
bool spec[n];
memset(spec,false,sizeof(spec));
int ans=0;
for(int i=0;i<(n+1)/2;i++){
set<vector<int>> s;
for(int i=0;i<n;i++){
//make i spec
if(spec[i]) continue;
int cost=0;
int a=0;
int b=v[i];
int c=0;
if(i) a=v[i-1];
if(i+1<n) c=v[i+1];
if(i&&v[i]<=v[i-1]){
cost+=v[i-1]-v[i]+1;
a=v[i]-1;
}
if(i+1<n&&v[i]<=v[i+1]){
cost+=v[i+1]-v[i]+1;
c=v[i+1]-1;
}
s.insert({cost,a,b,c,i});
}
auto it=s.begin();
ans+=(*it)[0];
cout<<ans<<" ";
spec[(*it)[4]]=1;
int ind=(*it)[4];
if(ind) v[ind-1]=(*it)[1];
if(ind+1<n) v[ind+1]=(*it)[3];
}
cout<<endl;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 0ms
memory: 3464kb
input:
3 1 2 4
output:
0 2
result:
ok 2 number(s): "0 2"
Test #2:
score: 7
Accepted
time: 0ms
memory: 3516kb
input:
3 3 2 1
output:
0 2
result:
ok 2 number(s): "0 2"
Test #3:
score: 7
Accepted
time: 0ms
memory: 3596kb
input:
3 1 2 1
output:
0 2
result:
ok 2 number(s): "0 2"
Test #4:
score: 7
Accepted
time: 0ms
memory: 3808kb
input:
3 3 3 3
output:
1 1
result:
ok 2 number(s): "1 1"
Test #5:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
input:
3 50 80 80
output:
1 3
result:
wrong answer 2nd numbers differ - expected: '31', found: '3'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%