結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
matsukin1111
|
| 提出日時 | 2019-04-15 23:47:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 240 ms / 5,000 ms |
| コード長 | 1,318 bytes |
| コンパイル時間 | 854 ms |
| コンパイル使用メモリ | 98,500 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 08:08:05 |
| 合計ジャッジ時間 | 1,632 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:65:25: warning: 'a2' may be used uninitialized [-Wmaybe-uninitialized]
65 | if (a1 < a2)temp += itm[i][2];
| ^~
main.cpp:60:33: note: 'a2' was declared here
60 | int a1, a2;
| ^~
main.cpp:65:25: warning: 'a1' may be used uninitialized [-Wmaybe-uninitialized]
65 | if (a1 < a2)temp += itm[i][2];
| ^~
main.cpp:60:29: note: 'a1' was declared here
60 | int a1, a2;
| ^~
ソースコード
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
int main() {
int n, m;
cin >> n >> m;
vector<int>itm[100];
rep(i, 0, m) {
int i1, i2, s;
cin >> i1 >> i2 >> s;
itm[i].pb(i1);
itm[i].pb(i2);
itm[i].pb(s);
}
vector<int>per(n);
rep(i, 0, n)per[i]=i;
int ans = -101010;
do {
int temp = 0;
rep(i, 0, m) {
int p1 = itm[i][0];
int p2 = itm[i][1];
int a1, a2;
rep(j, 0, n) {
if (per[j] == p1)a1 = j;
else if (per[j] == p2)a2 = j;
}
if (a1 < a2)temp += itm[i][2];
}
ans = max(ans, temp);
} while (next_permutation(all(per)));
cout << ans << endl;
return 0;
}
matsukin1111