#11761:


neilau7 (neilau7)

學校 : 中原大學
編號 : 64080
來源 : [59.124.159.30]
最後登入時間 :
2017-02-22 18:56:16
b972. 1.任務一->接力賽 | From: [59.124.159.30] | 發表日期 : 2017-02-22 18:57

#include <stdlib.h>
#include <stdio.h>

int main()
{
int n, t;

while (scanf("%d%d", &n, &t) != EOF) {
int total[20] = {0};
int m, s;
int i, j;

for (i = 0; i < n; i++)
for (j = 0; j < t; j++) {
scanf("%d:%d", &m, &s);
total[j] += (m * 60) + s;
}

//Bubble Sort
for (i = 0; i < t - 1; i++)
for (j = 0;j < t - 1 - i; j++) {
//total[0] will be minimum
if (total[j] > total[j + 1]) {
/* xor change
total[j] ^= total[j + 1];
total[j + 1] ^= total[j];
total[j] ^= total[j + 1];
*/
int temp = total[j];
total[j] = total[j + 1];
total[j + 1] = temp;
}
}

for (i = 0; i < t; i++)
printf("%d\n", total[i]);
}

return 0;
}

 
ZeroJudge Forum