結果

問題 No.90 品物の並び替え
ユーザー Mcpu3
提出日時 2019-03-08 16:07:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 261 ms / 5,000 ms
コード長 665 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 73,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 15:02:31
合計ジャッジ時間 1,481 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:22:25: warning: 'tmp3' may be used uninitialized [-Wmaybe-uninitialized]
   22 |                         if (tmp2 < tmp3) sum += score[j];
      |                         ^~
main.cpp:17:35: note: 'tmp3' was declared here
   17 |                         int tmp2, tmp3;
      |                                   ^~~~
main.cpp:22:25: warning: 'tmp2' may be used uninitialized [-Wmaybe-uninitialized]
   22 |                         if (tmp2 < tmp3) sum += score[j];
      |                         ^~
main.cpp:17:29: note: 'tmp2' was declared here
   17 |                         int tmp2, tmp3;
      |                             ^~~~

ソースコード

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

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> item1(M), item2(M), score(M);
for (int i = 0; i < M; ++i) cin >> item1[i] >> item2[i] >> score[i];
vector<int> tmp1(N);
for (int i = 0; i < N; ++i) tmp1[i] = i;
int ans = 0;
do {
int sum = 0;
for (int j = 0; j < M; ++j) {
int tmp2, tmp3;
for (int k = 0; k < N; ++k) {
if (tmp1[k] == item1[j]) tmp2 = k;
else if (tmp1[k] == item2[j]) tmp3 = k;
}
if (tmp2 < tmp3) sum += score[j];
}
ans = max(sum, ans);
} while (next_permutation(tmp1.begin(), tmp1.end()));
cout << ans;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0