| 比赛 |
期末考试1 |
评测结果 |
AAAAATTTAT |
| 题目名称 |
Communication |
最终得分 |
60 |
| 用户昵称 |
Ruyi |
运行时间 |
4.720 s |
| 代码语言 |
C++ |
内存使用 |
13.84 MiB |
| 提交时间 |
2026-02-08 11:07:10 |
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
#define N 500001
using namespace std;
const ll INF=1e18;
ll n,l,r,a[N],b[N],w[N],dp[N],tdp[N];
int main(){
freopen("tioj_communication.in","r",stdin);
freopen("tioj_communication.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>l>>r;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) cin>>b[i];
for(int i=1;i<=n;i++) cin>>w[i];
fill(dp+1,dp+n+1,-1);
dp[1]=w[1];
for(int round=1;round<=n;round++){
memcpy(tdp,dp,sizeof(tdp));
bool flag=false;
for(int u=1;u<=n;u++){
if(tdp[u]==-1) continue;
for(int v=1;v<=n;v++){
if(u==v) continue;
ll val=a[u]+b[v];
if(val<l||val>r) continue;
if(dp[v]==-1||tdp[u]+w[v]<dp[v]){
dp[v]=tdp[u]+w[v];
flag=true;
}
}
}
if(!flag) break;
}
for(int i=1;i<=n;i++) cout<<dp[i]<<' ';
cout<<endl;
return 0;
}