結果
問題 | No.90 品物の並び替え |
ユーザー |
![]() |
提出日時 | 2014-12-07 19:18:07 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 74 ms / 5,000 ms |
コード長 | 880 bytes |
コンパイル時間 | 417 ms |
コンパイル使用メモリ | 60,232 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-11 16:07:06 |
合計ジャッジ時間 | 947 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d%d", &N, &M); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d%d%d", &x, &y, &s); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>#include<iostream>#include<vector>#include<algorithm>#include<string>#include<cstring>using namespace std;typedef long long LL;typedef vector<int> VI;#define REP(i,n) for(int i=0; i<int(n); i++)#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)template<class T> inline T &amin(T &a, T b) { if (a>b) a=b; return a; }template<class T> inline T &amax(T &a, T b) { if (a<b) a=b; return a; }int N, M, F[9][9];int I[9];int main() {scanf("%d%d", &N, &M);REP (i, M) {int x, y, s;scanf("%d%d%d", &x, &y, &s);F[x][y] = s;}REP (i, N) I[i] = i;int ans = 0;do {int sum = 0;REP (i, N) {REP (j, N) {if (I[i] < I[j]) sum += F[i][j];}}amax(ans, sum);} while (next_permutation(I, I+N));printf("%d\n", ans);return 0;}