結果

問題 No.90 品物の並び替え
ユーザー goodbatongoodbaton
提出日時 2015-08-04 21:50:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 959 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 72,424 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 01:09:27
合計ジャッジ時間 1,341 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 9 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 10 ms
4,380 KB
testcase_06 AC 7 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 92 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL

#define SIZE 101


int main(){
    int n,m,a,b,c,ans=0;
    int item1[SIZE],item2[SIZE],score[SIZE];
    int per[9]={0,1,2,3,4,5,6,7,8};
    
    scanf("%d%d",&n,&m);
    
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&item1[i],&item2[i],&score[i]);
    }
    
    do{
        int dic[9]={0},S=0;
        
        for(int i=0;i<n;i++)
            dic[per[i]]=i;
        
        for(int i=0;i<m;i++){
            if(dic[item1[i]] < dic[item2[i]])
                S+=score[i];
        }
        
        ans=max(ans,S);
        
    }while(next_permutation(per,per+n));
    
    printf("%d",ans);
    
    return 0;
}
0