スキップしてメイン コンテンツに移動

投稿

ラベル(AtCoder)が付いた投稿を表示しています

ARC087 / ABC082 A~D解こうとしてみた。

 ARC087 / ABC082を解いたので、初心者なりに考え方などを書いて行きます。  AtCoderの解説放送を参考にしています。 https://www.youtube.com/watch?v=GDuzZIuWs2Q A - Round Up the Mean  a+b+1の平均を取れば良い。 #include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int a,b; cin >> a >> b; cout << (a+b+1) / 2 << endl; return 0; } B - Two Anagrams  s,tをソートして、tを逆順にして比較すればおk。 #include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); string s,t; cin >> s >> t; sort(s.begin(),s.end()); sort(t.begin(),t.end()); reverse(t.begin(),t.end()); cout << (s < t ? "Yes" : "No") << endl; return 0; } C - Good Sequence  数字が出てきた回数がその数字よりも少なかったら出てきた回数、多かったら回数-その数字で良い数列にすることができます。  数字が出てきた回数を数え上げるところで少し悩んだ。 #include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios...

ページビューの合計

ラベル一覧を表示