結果
問題 | No.90 品物の並び替え |
ユーザー | ciel |
提出日時 | 2014-11-28 17:50:59 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 328 ms / 5,000 ms |
コード長 | 524 bytes |
コンパイル時間 | 1,973 ms |
コンパイル使用メモリ | 76,156 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-01 22:45:11 |
合計ジャッジ時間 | 3,132 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 30 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 4 ms
4,376 KB |
testcase_04 | AC | 4 ms
4,376 KB |
testcase_05 | AC | 30 ms
4,380 KB |
testcase_06 | AC | 30 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 328 ms
4,376 KB |
ソースコード
#include <vector> #include <unordered_map> #include <algorithm> #include <numeric> #include <cstdio> using namespace std; int main(){ int N,M; scanf("%d%d",&N,&M); unordered_map<int,unordered_map<int,int> >m; for(;M--;){ int a,b,c; scanf("%d%d%d",&a,&b,&c); m[a][b]=c; } vector<int>v(N); iota(v.begin(),v.end(),0); int r=0; do{ int s=0; for(int i=0;i<N-1;i++)for(int j=i+1;j<N;j++)s+=m[v[i]][v[j]]; if(r<s)r=s; }while(next_permutation(v.begin(),v.end())); printf("%d\n",r); }