/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
int n, k, cntr = 0, j;
string s, s2 = "";
cin >> n >> k >> s;
for (int i = 0; cntr < k; i++){
s2 = s2 + s[i];
if (s[i] == 'C') cntr++;
}
cntr = 0;
for (j = n - 1; cntr < k; j--) if (s[j] == 'C') cntr++;
for (int i = j + 2; i < n; i++) s2 = s2 + s[i];
n = s2.length();
int dp[n + 1][n + 1];
for (int i = 0; i < n; i++) dp[i][i + 1] = 0;
for (int l = 1; l <= n; l++) for (int i = 0; i <= n - l; i++) dp[i][i + l] = l - 1 + min((int) (s2[i] == 'C') - dp[i + 1][i + l], (int) (s2[i + l - 1] == 'C') - dp[i][i + l - 1]);
cout << (dp[0][n] < k ? "DA" : "NE");
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |