結果

問題 No.90 品物の並び替え
ユーザー nxterunxteru
提出日時 2017-06-10 09:06:56
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 726 bytes
コンパイル時間 1,285 ms
コンパイル使用メモリ 29,824 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 20:21:55
合計ジャッジ時間 2,011 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 13 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 13 ms
4,348 KB
testcase_06 AC 10 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 139 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'max':
main.c:3:5: warning: type of 'i' defaults to 'int' [-Wimplicit-int]
    3 | int max(i){
      |     ^~~

ソースコード

diff #

#include <stdio.h>
int a[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},m,n,b[100],c[100],d[100];
int max(i){
    if(i==n){
        int x=0,j;
        for(j=0;j<m;j++){
           x+= a[b[j]]<a[c[j]]?d[j]:0;
        }
        return x;
    }else{
        int y=0,k,l;
        for(k=0;k<n;k++){
            int f=1;
            for(l=0;l<i;l++){
                if(a[l]==k){
                  f=0;
                }
            }
            if(f){
                a[i]=k;
                int w=max(i+1);
                y=w>y?w:y;
            }
        }
        return y;
    }
    
    
    
}


int main(void){
    scanf("%d%d",&n,&m);
   for(int i=0;i<m;i++){
       scanf("%d%d%d",&b[i],&c[i],&d[i]);
   }
   printf("%d",max(0));
}
0