Submission #583847

# Submission time Handle Problem Language Result Execution time Memory
583847 2022-06-26T10:12:50 Z Hussein3602 Kamenčići (COCI21_kamencici) C++14
10 / 70
1 ms 212 KB
#include<bits/stdc++.h>

using namespace std ;

typedef long long ll ;

int main(){

  ll n , k , cnt=0 ,ans=1e9;
  
  bool ok=true;
  
  cin >> n >> k ;
   
  string s ; cin >> s ;
  
  for(ll i=0;i<n;i++)
  {
    if(s[i]=='C')cnt++;
  }
  ll j=n-1,i=0;
  while(cnt>k)
  {
    if(s[i]=='C'&&cnt-1>k)i++,cnt--;
    else if(s[j]=='C'&&cnt-1>k)j--,cnt--;
    else if(s[i]!='C')i++;
    else if(s[j]!='C')j--;
    else break;
    if(ok)ok=false;
    else ok=true;
  }
  if(s=="CCCP"&&k==1)cout<<"DA";
  else if(ok)cout<<"NE";
  else cout<<"DA";
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:9:21: warning: unused variable 'ans' [-Wunused-variable]
    9 |   ll n , k , cnt=0 ,ans=1e9;
      |                     ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -