# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
98464 | 2019-02-23T18:23:43 Z | luciocf | Zoltan (COCI16_zoltan) | C++14 | 672 ms | 512 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 22; int num[maxn], dp[maxn], qtd[maxn]; int main(void) { int n, q = 0; cin >> n; for (int i = 0; i < n; i++) cin >> num[i]; int ans = 0; for (int mask = 0; mask < (1<<n); mask++) { int aux = 0; deque<int> dq; if (!(mask&1)) continue; for (int i = 0; i < n; i++) { if (mask&(1<<i)) dq.push_front(num[i]); else dq.push_back(num[i]); } vector<int> v; while (dq.size() > 0) { v.push_back(dq.front()); dq.pop_front(); } for (int i = 0; i < v.size(); i++) { dp[i] = qtd[i] = 1; for (int j = 0; j < i; j++) if (v[j] < v[i]) dp[i] = max(dp[i], dp[j]+1); } for (int i = 0; i < v.size(); i++) aux = max(aux, dp[i]); if (aux < ans) continue; if (aux > ans) q = 0; ans = aux; for (int i = 0; i < v.size(); i++) { if (dp[i] < ans) continue; q += qtd[i]; for (int j = 0; j < i; j++) if (v[j] < v[i] && dp[j]+1 == dp[i]) qtd[i] += qtd[j], q += qtd[j]; } } cout << ans << " " << q << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 630 ms | 256 KB | Output isn't correct |
2 | Incorrect | 672 ms | 504 KB | Output isn't correct |
3 | Incorrect | 625 ms | 384 KB | Output isn't correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Incorrect | 502 ms | 352 KB | Output isn't correct |
6 | Correct | 629 ms | 432 KB | Output is correct |
7 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
8 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
11 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
13 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
14 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
15 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
16 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
17 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
18 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
19 | Runtime error | 2 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
20 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |