結果

問題 No.90 品物の並び替え
コンテスト
ユーザー nxteru
提出日時 2017-06-10 09:06:56
言語 C11(gcc12 gnu拡張)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=gnu11 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 93 ms / 5,000 ms
コード長 726 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 100 ms
コンパイル使用メモリ 32,472 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 16:11:34
合計ジャッジ時間 657 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘max’:
main.c:3:5: warning: type of ‘i’ defaults to ‘int’ [-Wimplicit-int]
    3 | int max(i){
      |     ^~~
main.c: In function ‘main’:
main.c:34:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |     scanf("%d%d",&n,&m);
      |     ^~~~~~~~~~~~~~~~~~~
main.c:36:8: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |        scanf("%d%d%d",&b[i],&c[i],&d[i]);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#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