結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-28 17:50:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 363 ms / 5,000 ms |
| コード長 | 524 bytes |
| コンパイル時間 | 710 ms |
| コンパイル使用メモリ | 67,856 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-03 10:19:35 |
| 合計ジャッジ時間 | 1,953 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d%d",&N,&M);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d%d%d",&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#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);
}