Submission #341332

#TimeUsernameProblemLanguageResultExecution timeMemory
341332hackxsarasMiners (IOI07_miners)C++14
25 / 100
24 ms1256 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back int n; void solve(){ cin >> n; string s; cin >> s; int ans = 0; vector<int> minea, mineb; for(int i=0;i<n;i++){ set<char> a, b; a.insert(s[i]); if(minea.size())a.insert(minea.back()); if(minea.size() > 1)a.insert(*prev(prev(minea.end()))); b.insert(s[i]); if(mineb.size())b.insert(mineb.back()); if(mineb.size() > 1)b.insert(*prev(prev(mineb.end()))); if(a.size() == b.size()){ if(minea.size() < mineb.size()){ minea.pb(s[i]); } else { mineb.pb(s[i]); } } else if(a.size() > b.size()){ minea.pb(s[i]); //cout<<"a"; } else {mineb.pb(s[i]);}//cout<<"b";} ans += max(a.size(), b.size()); } cout<<"\n"; cout<<ans<<"\n"; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin>>t; while(t--){ solve(); } return 0; }
#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...