結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2019-02-18 11:55:15 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 15 ms / 5,000 ms |
コード長 | 1,333 bytes |
コンパイル時間 | 648 ms |
コンパイル使用メモリ | 81,980 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-05 12:43:42 |
合計ジャッジ時間 | 1,067 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <iostream>#include <cmath>#include <string>#include <algorithm>#include <set>#include <vector>#include <map>#include <list>#include <stack>#include <cstdio>#include <cstring>#include <cstdlib>#include <queue>#define mkp(a, b) make_pair(a, b)#define pb(t) push_back(t)#define ft first#define sc second#define pt(num) cout << num << "\n"#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD#define max(a, b) ((a)>(b) ? (a):(b))#define min(a, b) ((a)<(b) ? (a):(b))#define chmax(a, b) (a<b ? a=b : 0)#define chmin(a, b) (a>b ? a=b : 0)#define INF 1000000000000000000#define MOD 1000000007LL#define MAX 101010using namespace std;typedef long long ll;typedef pair<ll, ll> P;typedef map<ll, ll> Map;int main(void) {ll N, M;cin >> N >> M;ll i, j, k;ll g[11][11]={};vector<ll> v;ll fa[11]={};fa[0]=1;for(i=1; i<=N; i++) fa[i]=fa[i-1]*i;for(i=0; i<N; i++) v.pb(i);for(i=0; i<M; i++) {ll a, b, c;cin >> a >> b >> c;g[a][b]=c;}ll ans=0;for(k=0; k<fa[N]; k++) {ll t=0;for(i=0; i<v.size(); i++) {for(j=i+1; j<v.size(); j++) {t+=g[v[i]][v[j]];}}chmax(ans, t);next_permutation(v.begin(), v.end());}pt(ans);}