結果

問題 No.90 品物の並び替え
ユーザー matsukin1111matsukin1111
提出日時 2019-04-15 23:47:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 239 ms / 5,000 ms
コード長 1,318 bytes
コンパイル時間 925 ms
コンパイル使用メモリ 98,928 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 06:53:53
合計ジャッジ時間 1,781 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 19 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 4 ms
4,348 KB
testcase_05 AC 21 ms
4,348 KB
testcase_06 AC 16 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 239 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
      |                             ^~

ソースコード

diff #

#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;
}
0