# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1025623 | amirhoseinfar1385 | Wiring (IOI17_wiring) | C++17 | 4 ms | 8796 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wiring.h"
#include<bits/stdc++.h>
using namespace std;
const long long maxn=200000+10;
long long dp[maxn],inf=1e16,vas[maxn];
long long n,m,ps[maxn];
vector<long long>allind;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
n=(long long)r.size();
m=(long long)b.size();
allind.push_back(-1);
for(auto x:r){
allind.push_back(x);
}
for(auto x:b){
allind.push_back(x);
}
sort(allind.begin(),allind.end());
allind.resize(unique(allind.begin(),allind.end())-allind.begin());
for(long long i=0;i<n;i++){
r[i]=lower_bound(allind.begin(),allind.end(),r[i])-allind.begin();
vas[r[i]]=1;
}
for(long long i=0;i<m;i++){
b[i]=lower_bound(allind.begin(),allind.end(),b[i])-allind.begin();
vas[b[i]]=2;
}
for(long long i=1;i<maxn;i++){
dp[i]=inf;
ps[i]=ps[i-1]+allind[i];
}
dp[0]=0;
long long sz=(long long)allind.size();
if(sz!=n+m+1){
exit(23);
}
for(long long i=1;i<sz;i++){
long long av=allind[i],unnow=0,last=i,bar=0,akh;
for(long long j=i-1;j>=1;j--){
if(vas[j]==vas[i]&&vas[j]!=vas[j+1]){
break;
}
if(vas[j]==vas[i]){
last=j;
unnow+=av;
av=allind[j];
}else{
bar+=allind[j];
akh=allind[last-1];
long long ted1=i-last+1;
long long ted2=(last-1)-j+1;
dp[i]=min(dp[i],min(dp[j],dp[j-1])+(ps[i]-ps[last-1])-(allind[last]*ted1)-(ps[last-1]-ps[j-1])+(allind[j]*ted2)+abs(ted2-ted1)*(allind[last]-allind[last-1]));
}
}
// cout<<i<<" "<<dp[i]<<" "<<vas[i]<<endl;
}
return dp[sz-1];
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |