Submission #583847

#TimeUsernameProblemLanguageResultExecution timeMemory
583847Hussein3602Kamenčići (COCI21_kamencici)C++14
10 / 70
1 ms212 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...