結果
問題 | No.90 品物の並び替え |
ユーザー | 184 |
提出日時 | 2014-12-07 20:29:58 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 241 ms / 5,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 423 ms |
コンパイル使用メモリ | 45,256 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 16:29:29 |
合計ジャッジ時間 | 1,161 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | int n,m;scanf("%d%d",&n,&m); | ~~~~~^~~~~~~~~~~~~~ main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%d%d%d",&a,&b,&score); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <vector> #include <algorithm> using namespace std; //遅刻 namaega184 int main(){ int n,m;scanf("%d%d",&n,&m); vector< vector<int> > v(n),item(n); int a,b,score; for(int i=0;i<m;i++){ scanf("%d%d%d",&a,&b,&score); v[a].push_back(score); item[a].push_back(b); } int perm[100];for(int i=0;i<n;i++)perm[i]=i; int ans=0; do{ score=0; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ for(int k=0;k<item[perm[i]].size();k++){ if(item[perm[i]][k]==perm[j])score+=v[perm[i]][k]; } } } if(score>ans)ans=score; } while(next_permutation(perm,perm+n)); printf("%d\n",ans); return 0; }