Submission #991870

#TimeUsernameProblemLanguageResultExecution timeMemory
991870tamir1Miners (IOI07_miners)C++17
25 / 100
3 ms860 KiB
#include<bits/stdc++.h> using namespace std; int n,i,j,ans,x[100005],p,q; string s; array<int,3> a,b; int give(int a,int b,int c){ int ans=0; if(a==1 || b==1 || c==1) ans++; if(a==2 || b==2 || c==2) ans++; if(a==3 || b==3 || c==3) ans++; return ans; } array<int,3> split(array<int,3> a,int val){ return {val,a[0],a[1]}; } int main(){ cin >> n >> s; for(i=0;i<n;i++){ if(s[i]=='M') x[i]=1; if(s[i]=='F') x[i]=2; if(s[i]=='B') x[i]=3; } for(i=0;i<n;i++){ if(a==b){ a=split(a,x[i]); ans+=give(a[0],a[1],a[2]); continue; } p=give(x[i],a[0],a[1]); q=give(x[i],b[0],b[1]); if(p>q){ a=split(a,x[i]); ans+=p; continue; } else{ b=split(b,x[i]); ans+=q; continue; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...