結果
| 問題 | No.286 Modulo Discount Store |
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2015-10-09 22:36:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,113 bytes |
| 記録 | |
| コンパイル時間 | 1,415 ms |
| コンパイル使用メモリ | 162,852 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-20 04:13:17 |
| 合計ジャッジ時間 | 4,843 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 2 TLE * 1 -- * 37 |
ソースコード
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>
typedef std::int_fast32_t s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t s64;
typedef std::uint_fast64_t u64;
const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);
typedef std::pair<int, int> pii;
template<typename T>
void print_array(T *A_, s32 size) {
//printf("%d\n", size);
if( size != 0 ) {
for(int i = 0; i < size - 1; ++i) {
printf("%d ", A_[i]);
}
printf("%d\n", A_[size - 1]);
}
}
auto solve(int n, std::vector<int> &m) -> int {
int mod = 0;
int res = 0;
for(int i = 0; i < n; ++i) {
res += std::max(0, m[i] - mod);
mod += m[i];
mod %= 1000;
}
return res;
}
auto main() -> int {
int n;
std::vector<int> m;
std::cin >> n;
for(int i = 0; i < n; ++i) {
int temp;
std::cin >> temp;
m.push_back(temp);
}
std::sort(m.begin(), m.end());
int res = INF;
do {
res = std::min(res, solve(n, m));
} while( next_permutation(m.begin(), m.end()) );
std::cout << res << std::endl;
return 0;
}
alpha_virginis