Cod sursa(job #2254604)
| Utilizator | Data | 5 octombrie 2018 16:58:04 | |
|---|---|---|---|
| Problema | Cc | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <fstream>
#define N 100
using namespace std;
ifstream f("cc.in");
ofstream g("cc.out");
int n,sum;
int dist[N][N];
bool chosen[N];
int main()
{
f>>n;
for(int i = 1; i <= n; i++){
for(int j = 1; j<= n; j++){
f>>dist[i][j];
}
}
for(int i = 1; i<=n; i++)
{
int Min = 999999999,ct = 0;
for(int j = 1; j<= n; j++)
{
if(Min>=dist[i][j] && !chosen[j]){
Min = dist[i][j];
ct = j;
}
}
sum+=Min;
chosen[ct] = 1;
}
g<<sum;
f.close();
g.close();
return 0;
}
