A - A Healthy Breakfast
https://atcoder.jp/contests/abc360/tasks/abc360_a
https://atcoder.jp/contests/abc360/submissions/55049596
int main() { string s; cin >> s; int ri, mi; for(int i=0; i<s.size(); i++){ if (s[i] == 'R'){ ri = i; } else if (s[i] == 'M'){ mi = i; } } if (ri < mi){ cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
B - Vertical Reading
https://atcoder.jp/contests/abc360/tasks/abc360_b
https://atcoder.jp/contests/abc360/submissions/55073344
string s, t; int main() { cin >> s >> t; int len = s.size(); vector<char> cache[105]; for(int w=1; w<=len-1; w++){ for(int i=0; i<105; i++){ cache[i].clear(); } int iter = 0; while(iter < len){ int row = iter/w; cache[row].push_back(s[iter]); iter++; } /* iterate every column */ for(int i=0; i<w; i++){ string res; /* iterate every row */ for(int j=0; j<100; j++){ if (i < cache[j].size()){ res += cache[j][i]; } else { break; } } if (res == t){ cout << "Yes" << endl; return 0; } } } cout << "No" << endl; return 0; }
C - Move It
https://atcoder.jp/contests/abc360/tasks/abc360_c
https://atcoder.jp/contests/abc360/submissions/55082543
typedef long long ll; ll n; ll a[100005]; ll w[100005]; map<ll, vector<ll>> buckets; int main() { cin >> n; for(int i=0; i<n; i++){ cin >> a[i]; } for(int i=0; i<n; i++){ cin >> w[i]; } for(int i=0; i<n; i++){ int bucket_number = a[i]; buckets[bucket_number].push_back(w[i]); } ll sum = 0; for(auto& one: buckets){ vector<ll>& weights = one.second; sort(weights.begin(), weights.end()); for(int i=0; i<weights.size()-1; i++){ sum += weights[i]; } } cout << sum << endl; return 0; }
D - Ghost Ants
https://atcoder.jp/contests/abc360/tasks/abc360_d
https://atcoder.jp/contests/abc360/submissions/55099937
typedef long long ll; ll n, t; string s; ll x[200005]; int main() { cin >> n >> t; cin >> s; for(int i=0; i<n; i++){ cin >> x[i]; } vector<ll> positive, negative; for(int i=0; i<n; i++){ if (s[i] == '1'){ positive.push_back(x[i]); } else { negative.push_back(x[i]); } } sort(positive.begin(), positive.end()); sort(negative.begin(), negative.end()); ll cnt = 0; for(ll i=0; i<positive.size(); i++){ vector<ll>::iterator range1, range2; range1 = upper_bound(negative.begin(), negative.end(), positive[i]); range2 = upper_bound(negative.begin(), negative.end(), positive[i]+2*t); ll diff = distance(range1, range2); cnt += diff; } cout << cnt << endl; return 0; }