Problem 1001 cÓïÑÔ

cangcang2017 | 2021-07-26 14:28:40Author
#include<stdio.h> int n,m,ship[3001][3001],count[3001]={0}; int main(){ int i,j; scanf("%d %d",&n,&m); for(i=1;i<=m;i++){ scanf("%d %d %d",&a,&b,&c); ship[a][b]=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); getchar();getchar(); return 0; }