- 题解
Codeforces Round 916 (Div. 3)
- @ 2023-12-20 10:40:38
1 comments
-
admin 菜比学长想拿牌子 SU @ 2023-12-20 10:46:05Edited
题意 有A-Z的题目,解决他们分别需要花费1-26分钟,一共有n分钟,每分钟monocarp都会思考某道题,问你他一共做出来了几道题?
解题思路 可以用map或者hash存下每道题已经花费的时间,如果刚好等于解决这道题需要花费的时间的时候就ans++;
code
#include<bits/stdc++.h> using namespace std; int t,n; string s; int main(){ cin>>t; while(t--) { cin>>n; cin>>s; int use[100]={0},ans=0; for(int i=0;i<s.length();i++) { use[ s[i]-'A' ]++; if( use[ s[i]-'A' ]==s[i]-'A'+1 ) ans++; } cout<<ans<<endl; } }
- 1