Showing posts with label AtCoder Beginner Contest 136. Show all posts
Showing posts with label AtCoder Beginner Contest 136. Show all posts

Sunday, September 15, 2019

AtCoder Beginner Contest 136(A - Transfer)

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int a, b, c;
  6. cin >> a >> b >> c;
  7. cout << ((a-b > c)? 0 : c-(a-b)) << endl;
  8. return 0;
  9. }

AtCoder Beginner Contest 136(B - Uneven Numbers)

  1. #include< bits/stdc++.h >
  2. using namespace std;
  3. int main(){
  4. int n, ans = 0;
  5. cin >> n;
  6. for(int i = 1; i <= n; i++) {
  7. string s;
  8. stringstream ss;
  9. ss << i;
  10. ss >> s;
  11. if(s.size()%2) ans++;
  12. }
  13. cout << ans << endl;
  14. return 0;
  15. }

AtCoder Beginner Contest 136(C - Build Stairs)

  1. #include< bits/stdc++.h >
  2. using namespace std;
  3. int main()
  4. {
  5. int n, m;
  6. int vc[100001];
  7. cin >> n;
  8. for(int i = 0; i < n; i++){
  9. cin >> vc[i];
  10. }
  11. for(int i = n - 1; i > 0; i--) {
  12. if(vc[i] < vc[i-1]) vc[i - 1] -= 1;
  13. }
  14. for(int i = 1; i < n; i++) {
  15. if(vc[i-1] > vc[i]) return cout << "No" << endl, 0;
  16. }
  17. cout << "Yes" << endl;
  18. return 0;
  19. }