結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
Gredt8
|
| 提出日時 | 2019-08-14 15:18:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 375 ms / 5,000 ms |
| コード長 | 2,172 bytes |
| コンパイル時間 | 1,046 ms |
| コンパイル使用メモリ | 96,352 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 14:28:19 |
| 合計ジャッジ時間 | 2,252 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>
#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << n); bit++)
using namespace std;
template<class T>
void print(const T &value) {
std::cout << value << std::endl;
}
void yesno(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; }
void YesNo(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }
void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }
typedef long long ll;
typedef unsigned long ul;
typedef long double ld;
template<class T>
inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T>
inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll INF = 10000000;
ll mod = 1000000007;//10^9+7
int dx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int dy[8] = {0, -1, 1, 0, -1, 1, -1, 1};
using Graph = vector<vector<int>>;//隣接リスト:G[i]にはiと隣接する頂点が入るよ。
using P = pair<int, int>;//BFSで利用。queueに入れる。
using PP = pair<int, P>; //dijkstraで利用,priority_queueに入れる。
using p_queue = priority_queue<int, vector<int>, greater<int>()>;
//struct edge{int to, cost};
//番号ズレ注意!!
int main() {
int N, M;
cin >> N >> M;
int item1[M], item2[M], score[M];
map<P, int> point;
REP(i, M) {
cin >> item1[i] >> item2[i] >> score[i];
point[make_pair(item1[i], item2[i])] = score[i];
}
vector<int> v;
REP(i, N) {
v.push_back(i);
}
int ans = 0;
while (next_permutation(v.begin(), v.end())) {
int sum = 0;
REP(i, N - 1) {
for (int j = i + 1; j < N; j++) {
sum += point[make_pair(v[i], v[j])];
}
}
ans = max(ans, sum);
}
print(ans);
}
Gredt8