Problem 1001 cÓïÑÔ

cangcang2017 | 2021-07-26 15:40:39Author
#include<stdio.h> int n,m; int ship[3001][3001]={0},count[3001]={0}; int i,j; int a,b,c; int main(){ while(scanf("%d%d",&n,&m)!=EOF){ for(i=1;i<=m;i++){ scanf("%d%d%d",&a,&b,&c); ship[a][b]=c; ship[b][a]=c; } int min_ship=0; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ if(ship[i][j]!=0){ count[i]+=ship[i][j]; } if(j==n&&count[i]<min_ship){ min_ship=count[i]; } } if(i==1){ min_ship=count[1]; } } printf("%d",min_ship); } return 0; }