結果

問題 No.90 品物の並び替え
ユーザー motumotu
提出日時 2014-12-07 19:36:53
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 1,724 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 85,476 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-11 16:11:05
合計ジャッジ時間 1,422 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define CLEAR(d) memset((d), 0, (sizeof((d))))
#define ALL(c) (c).begin(), (c).end()
#define ABS(x) ((x < 0) ? -(x) : (x))
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define SIZE(a) ((int)((a).size()))
#define MOD 1000000007
#define EPS 1e-10
#define PI (acos(-1))
#define INF 10000000
struct edge { int to; int cost; };
//===================================================
int main()
{
int n, m, ans = 0;
cin >> n >> m;
vector<int> item1(m), item2(m), score(m);
REP(i, m) {
cin >> item1[i] >> item2[i] >> score[i];
}
vector<int> data;
REP(i, n) data.push_back(i);
do{
int sum = 0;
int use[10] = { 0 };
CLEAR(use);
for (int i = 0; i < data.size(); i++) {
use[data[i]] = 1;
if (i == 0) {
continue;
}
for (int j = 0; j < m; j++) {
if (item1[j] != data[i]) continue;
if (use[item2[j]] == 1) sum += score[j];
}
}
ans = max(ans, sum);
} while (next_permutation(data.begin(), data.end()));
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0