Submission #499436

#TimeUsernameProblemLanguageResultExecution timeMemory
499436Haboosh915Kamenčići (COCI21_kamencici)C++17
70 / 70
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n , k , kf = 0 , ks = 0 ; cin >> n >> k ; int i = 0 ,j = n-1; string s; cin >>s ; while (i < j && (kf < k || ks <k) ){ if (s[i]=='P'){ i++; } else if (s[j]=='P'){ j--; } else if (s[i]=='C' && s[i+1]=='C'){ kf++; i++; } else if (s[j]=='C' && s[j-1]=='C'){ kf++; j--; } else if (s[i]=='C'){ kf++; i++; } if (kf >= k) break; if (s[i]=='P'){ i++; } else if (s[j]=='P'){ j--; } else if (s[i]=='C' && s[i+1]=='C'){ ks++; i++; } else if (s[j]=='C' && s[j-1]=='C'){ ks++; j--; } else if (s[i]=='C'){ ks++; i++; } if (ks >= k)break; } if ( ks > kf ) cout << "DA" ; else cout<<"NE"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...