本文主要是介绍AtCoder Beginner Contest 329,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
A - Spread (atcoder.jp)
AC代码:
#include<bits/stdc++.h>
#define endl '\n'
//#define int long long
using namespace std;
string s;
void solve() {cin>>s;for(int i=0;i<(int)s.size();i++) cout<<s[i]<<' ';cout<<endl;
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int t=1;
// cin>>t;while(t--) {solve();}return 0;
}
B - Next (atcoder.jp)
AC代码:
#include<bits/stdc++.h>
#define endl '\n'
//#define int long long
using namespace std;
int n;
void solve() {cin>>n;set<int,greater<int>>s;for(int i=0;i<n;i++){int x;cin>>x;s.insert(x);}s.erase(s.begin());cout<<*s.begin()<<endl;
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int t=1;
// cin>>t;while(t--) {solve();}return 0;
}
C - Count xxx (atcoder.jp)
AC代码:
#include<bits/stdc++.h>
#define endl '\n'
//#define int long long
using namespace std;
int n;
string s;
void solve() {cin>>n;cin>>s;map<char,int>mp;int cnt=1;for(int i=1;i<n;i++){ if(s[i]!=s[i-1]){mp[s[i-1]]=max(mp[s[i-1]],cnt);cnt=1;}else cnt++;}mp[s[n-1]]=max(mp[s[n-1]],cnt);int ans=0;for(char i='a';i<='z';i++){ans+=mp[i];}cout<<ans<<endl;
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int t=1;
// cin>>t;while(t--) {solve();}return 0;
}
D - Election Quick Report (atcoder.jp)
AC代码:
#include<bits/stdc++.h>
#define endl '\n'
//#define int long long
using namespace std;
typedef pair<int,int>PII;
priority_queue<PII>q;
int n,m;
void solve() {cin>>n>>m;map<int,int>mp;for(int i=0;i<m;i++){int x;cin>>x;mp[x]++;q.push({mp[x],-x});cout<<-q.top().second<<endl;}
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int t=1;
// cin>>t;while(t--) {solve();}return 0;
}
这篇关于AtCoder Beginner Contest 329的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!