結果
問題 | No.711 競技レーティング単調増加 |
ユーザー |
![]() |
提出日時 | 2017-05-23 00:49:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 785 bytes |
コンパイル時間 | 1,588 ms |
コンパイル使用メモリ | 173,304 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-19 10:32:25 |
合計ジャッジ時間 | 11,752 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 31 |
ソースコード
// O(n^2) のTLE解を X 個だけ持って、O(NX) にした WA 解 #include <bits/stdc++.h> using namespace std; int solve() { int n; cin >> n; vector<int> A(n); for (int i = 0; i < n; i++) cin >> A[i]; vector<pair<int, int>> q1, q2; auto &cur = q1; auto &nex = q2; cur.emplace_back(0, 0); const int X = 1000; for (int i = 0; i < n; i++) { for (auto cl : cur) { if (nex.size() > X) break; int c = cl.first; int l = cl.second; if (l < A[i]) { nex.emplace_back(c, A[i]); } nex.emplace_back(c + 1, l + 1); } swap(cur, nex); nex.clear(); } return min_element(cur.begin(), cur.end())->first; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << solve() << endl; return 0; }