結果

問題 No.1628 Sorting Integers (MAX of M)
ユーザー ohreitetsuohreitetsu
提出日時 2021-08-28 22:44:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 77,248 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 05:11:44
合計ジャッジ時間 1,666 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 160 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long LL;
int main()
{
	int N,i;
	cin >> N;
	vector<int> myVec;
	for (i = 1; i <= 9;i++) {
		int c;
		cin >> c;
		for (int j = 0; j < c; j++) {
			myVec.push_back(i);
		}
	}
	LL Max = 0;
	do {
		LL M = 0;
		int Len = myVec.size();
		for (i = 0; i < myVec.size(); i++) {
			M += myVec[i] * pow(10.0, Len - 1);
			Len--;
		}
		if (Max < M) {
			Max = M;
		}
	} while (next_permutation(myVec.begin(), myVec.end()));
	cout << Max << endl;
	return 0;
}
0