結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2015-01-31 20:14:26 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 2,615 ms / 5,000 ms |
コード長 | 1,551 bytes |
コンパイル時間 | 442 ms |
使用メモリ | 3,560 KB |
最終ジャッジ日時 | 2023-01-21 14:15:48 |
合計ジャッジ時間 | 14,267 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
3,520 KB |
testcase_01 | AC | 2 ms
3,460 KB |
testcase_02 | AC | 1,428 ms
3,552 KB |
testcase_03 | AC | 1,000 ms
3,468 KB |
testcase_04 | AC | 429 ms
3,552 KB |
testcase_05 | AC | 243 ms
3,464 KB |
testcase_06 | AC | 59 ms
3,524 KB |
testcase_07 | AC | 2 ms
3,544 KB |
testcase_08 | AC | 91 ms
3,452 KB |
testcase_09 | AC | 1,332 ms
3,524 KB |
testcase_10 | AC | 2 ms
3,560 KB |
testcase_11 | AC | 2,615 ms
3,464 KB |
testcase_12 | AC | 66 ms
3,528 KB |
testcase_13 | AC | 1,526 ms
3,528 KB |
testcase_14 | AC | 1,332 ms
3,448 KB |
testcase_15 | AC | 1,204 ms
3,556 KB |
testcase_16 | AC | 7 ms
3,476 KB |
testcase_17 | AC | 646 ms
3,552 KB |
testcase_18 | AC | 512 ms
3,524 KB |
testcase_19 | AC | 4 ms
3,544 KB |
ソースコード
//No.9 モンスターのレベル上げ #include <iostream> #include <limits.h> #include <algorithm> #include <cstring> #define N_MAX 1500 using namespace std; int N; typedef struct { int Level; int Count; } FM; bool compFm(const FM& x, const FM& y) { if (x.Level != y.Level) return x.Level < y.Level; else return x.Count < y.Count; } bool compC(const FM& x, const FM& y) { return x.Count > y.Count; } void swap(FM& x, FM& y) { FM t = y; y = x; x = t; } void resort_old(FM* fm) { for (int i = 0; i < N - 1; ++i) if (fm[i].Level > fm[i + 1].Level || (fm[i].Level == fm[i + 1].Level && fm[i].Count > fm[i + 1].Count)) swap(fm[i], fm[i + 1]); } void resort(FM* fm) { FM t = fm[0]; for (int i = 1; i < N; ++i) { if (t.Level > fm[i].Level || (t.Level == fm[i].Level && t.Count > fm[i].Count) ) continue; --i; memcpy(fm, fm + 1, sizeof(FM)*i); fm[i] = t; return; } memcpy(fm, fm + 1, sizeof(FM)*(N-1)); fm[N-1] = t; } int main() { FM A[N_MAX], AA[N_MAX]; int B[N_MAX]; int ans = INT_MAX; cin >> N; std::memset(A, 0, sizeof(A)); for (int i = 0; i < N; ++i) { cin >> A[i].Level; } for (int i = 0; i < N; ++i) cin >> B[i]; sort(A, A + N, compFm); //最初の敵選択ループ for (int f = 0; f < N; ++f) { std::memcpy(AA, A, sizeof(FM)*N); for (int i = 0; i < N; ++i) { int t = (f + i) % N; AA[0].Level += B[t] / 2; ++(AA[0].Count); resort(AA); } sort(AA, AA + N, compC); if (AA[0].Count < ans) ans = AA[0].Count; } cout << ans << endl; return 0; }