結果
問題 | No.1628 Sorting Integers (MAX of M) |
ユーザー |
|
提出日時 | 2021-08-28 22:44:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 85 ms / 2,000 ms |
コード長 | 557 bytes |
コンパイル時間 | 830 ms |
コンパイル使用メモリ | 77,424 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 23:33:31 |
合計ジャッジ時間 | 1,586 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 6 |
ソースコード
#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; }