結果

問題 No.90 品物の並び替え
ユーザー ytftytft
提出日時 2022-11-10 01:05:11
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 483 bytes
コンパイル時間 2,803 ms
コンパイル使用メモリ 241,736 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 11:46:57
合計ジャッジ時間 3,375 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 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 2 ms
4,380 KB
testcase_05 AC 10 ms
4,380 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 107 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,M,i,j,cur,ans=0;
    scanf("%d%d",&N,&M);
    int score[M][3],ord[N];
    for(i=0;i<M;++i){
    	for(j=0;j<3;++j){
    		scanf("%d",&score[i][j]);
    	}
    }
    for(i=0;i<N;++i)ord[i]=i;
    do{
    	cur=0;
    	for(i=0;i<M;++i){
    		if(ord[score[i][0]]<ord[score[i][1]]){
    			cur+=score[i][2];
    		}
    	}
    	if(ans<cur){
    		ans=cur;
    	}
	}while(next_permutation(ord,ord+N));
	printf("%d\n",ans);
}
0