Submission #98464

#TimeUsernameProblemLanguageResultExecution timeMemory
98464luciocfZoltan (COCI16_zoltan)C++14
14 / 140
672 ms512 KiB
#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 (stderr)

zoltan.cpp: In function 'int main()':
zoltan.cpp:41:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < v.size(); i++)
                   ~~^~~~~~~~~~
zoltan.cpp:49:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < v.size(); i++) aux = max(aux, dp[i]);
                   ~~^~~~~~~~~~
zoltan.cpp:56:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < v.size(); i++)
                   ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...