第一次参加 AtCoder 的比赛,感觉还挺简单。

比赛链接:https://atcoder.jp/contests/abc189

A - Slot

  1. // Author : RioTian
  2. // Time : 21/01/23
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. typedef long long ll;
  6. const int N = 1e5 + 10;
  7. int main() {
  8. // freopen("in.txt","r",stdin);
  9. ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  10. string s;
  11. cin >> s;
  12. if (s[0] == s[1] && s[1] == s[2])
  13. cout << "Won\n";
  14. else
  15. cout << "Lost\n";
  16. }

B - Alcoholic

高桥(大家都喜欢的高桥同学)要喝酒了,现在有n中酒,如果高桥同学喝酒的量大于 AtCoder Beginner Contest 189 Personal Editorial - 图1则会喝酒离开酒席。那么请输出高桥是在第几个酒上喝醉了,如果没有喝醉请输出 -1

  1. // Author : RioTian
  2. // Time : 21/01/24
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. typedef long long ll;
  6. const int N = 1e5 + 10;
  7. int main() {
  8. // freopen("in.txt","r",stdin);
  9. ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  10. int n, v, p, x;
  11. int sum = 0;
  12. cin >> n >> x;
  13. for (int i = 1; i <= n; ++i) {
  14. cin >> v >> p;
  15. sum += v * p;
  16. if (sum > x * 100) {
  17. cout << i << endl;
  18. return 0;
  19. }
  20. }
  21. cout << -1 << endl;
  22. }

C - Mandarin

求最大连续序列和,但由于n比较小直接暴力即可。

  1. // Author : RioTian
  2. // Time : 21/01/24
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. typedef long long ll;
  6. const int N = 1e5 + 10;
  7. int a[N];
  8. int main() {
  9. // freopen("in.txt","r",stdin);
  10. ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  11. int n;
  12. cin >> n;
  13. for (int i = 0; i < n; ++i) cin >> a[i];
  14. int ans = 0;
  15. for (int l = 0; l < n; ++l) {
  16. int x = a[l];
  17. for (int r = l; r < n; ++r) {
  18. x = min(x, a[r]);
  19. ans = max(ans, x * (r - l + 1));
  20. }
  21. }
  22. cout << ans << endl;
  23. }

D - Logical Expression

如果 AtCoder Beginner Contest 189 Personal Editorial - 图2AND 则 opt 设为 true,在之后只要 AtCoder Beginner Contest 189 Personal Editorial - 图3%20%3D%20f(S1%2C…%2CS%7BN-1%7D)#card=math&code=f%28S1%2C…%2CS_N%29%20%3D%20f%28S_1%2C…%2CS%7BN-1%7D%29)

如歌 AtCoder Beginner Contest 189 Personal Editorial - 图4OR 则 opt 设为 false,需要 AtCoder Beginner Contest 189 Personal Editorial - 图5%20%3D%202%5EN%20%2B%20f(S1%2C…%2CS%7BN-1%7D)#card=math&code=f%28S1%2C…%2CS_N%29%20%3D%202%5EN%20%2B%20f%28S_1%2C…%2CS%7BN-1%7D%29)

  1. // Author : RioTian
  2. // Time : 21/01/24
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. typedef long long ll;
  6. const int N = 100;
  7. ll dp[N][2];
  8. bool opt[N];
  9. string s;
  10. int main() {
  11. // freopen("in.txt","r",stdin);
  12. ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  13. int n;
  14. cin >> n;
  15. for (int i = 0; i < n; ++i) {
  16. cin >> s;
  17. if (s[0] == 'A')
  18. opt[i] = true;
  19. else
  20. opt[i] = false;
  21. }
  22. dp[0][0] = dp[0][1] = 1;
  23. for (int i = 1; i <= n; ++i) {
  24. if (opt[i - 1]) {
  25. dp[i][0] = 2 * dp[i - 1][0] + dp[i - 1][1];
  26. dp[i][1] = dp[i - 1][1];
  27. } else {
  28. dp[i][0] = dp[i - 1][0];
  29. dp[i][1] = 2 * dp[i - 1][1] + dp[i - 1][0];
  30. }
  31. }
  32. cout << dp[n][1] << endl;
  33. }

E,F比赛时没做就先鸽一下了