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

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

A - Slot

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

B - Alcoholic

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

// Author : RioTian
// Time : 21/01/24
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n, v, p, x;
int sum = 0;
cin >> n >> x;
for (int i = 1; i <= n; ++i) {
cin >> v >> p;
sum += v * p;
if (sum > x * 100) {
cout << i << endl;
return 0;
}
}
cout << -1 << endl;
}

C - Mandarin

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

// Author : RioTian
// Time : 21/01/24
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int a[N];
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i]; int ans = 0;
for (int l = 0; l < n; ++l) {
int x = a[l];
for (int r = l; r < n; ++r) {
x = min(x, a[r]);
ans = max(ans, x * (r - l + 1));
}
}
cout << ans << endl;
}

D - Logical Expression

如果 \(S_i\) 是 AND 则 opt 设为 true,在之后只要 \(f(S_1,...,S_N) = f(S_1,...,S_{N-1})\)

如歌 \(S_i\) 是 OR 则 opt 设为 false,需要 \(f(S_1,...,S_N) = 2^N + f(S_1,...,S_{N-1})\)

// Author : RioTian
// Time : 21/01/24
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100; ll dp[N][2];
bool opt[N];
string s; int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> s; if (s[0] == 'A')
opt[i] = true;
else
opt[i] = false;
} dp[0][0] = dp[0][1] = 1;
for (int i = 1; i <= n; ++i) {
if (opt[i - 1]) {
dp[i][0] = 2 * dp[i - 1][0] + dp[i - 1][1];
dp[i][1] = dp[i - 1][1];
} else {
dp[i][0] = dp[i - 1][0];
dp[i][1] = 2 * dp[i - 1][1] + dp[i - 1][0];
}
} cout << dp[n][1] << endl;
}

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

AtCoder Beginner Contest 189 Personal Editorial的更多相关文章

  1. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  2. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  3. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  4. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  5. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  6. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  7. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  8. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  9. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】

    AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...

  10. AtCoder Beginner Contest 075 C bridge【图论求桥】

    AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...

随机推荐

  1. java.util.List如何用

    起因是这样,我在学习Javaweb,然后就突然有很多类似的语句 这是什么意思呢?让我们一起来解决看看吧! List有序集合(也成为序列),用户可以精确控制列表中每个元素的插入位置.用户可以通过整数索引 ...

  2. 轻量级SpringBoot配置中心 - Minimal-Config

    介绍 minimal-config-spring-boot-starter,是基于Spring-Boot原生配置注入实现原理的基础上,拓展的轻量级配置中心,项目体积只有24KB,设计理念为服务中小型项 ...

  3. 吉特日化MES系统&生产工艺控制参数对照表

    吉特日化MES生产工艺参数对照表 工艺编号 PROCE_BASE_TIMER 工艺名称 定时器 工艺说明 主要用于生产工艺步骤过程计时 参数编号 参数名称 参数描述 Prop_Timer_Enable ...

  4. docker 设计及源码分析

    1.dockerd 是一个长期运行的守护进程(docker daemon).负责管理 docker 容器的生命周期.镜像和存储等.实际还是通过grpc 的协议调用 containerd 的 api 接 ...

  5. 【2020】装了VirtualBox后VMware Workstation无法使用SSH连接Centos的解决方法

    装了个VirtualBox,然后发现无法使用Xshell远程Vmware中的centos了,一开始感觉是虚拟网卡冲突了,发现把VirtualBox的虚拟网卡禁用就可以使用,但是好麻烦啊??每次我特么要 ...

  6. 复习:Java基础-泛型方法

    泛型 大家都很熟悉了 泛型方法呢 可能很多小伙伴都有混淆,今天来稍微复习一下 泛型方法(普通方法) public class Test<T> { public T f(T c) { //注 ...

  7. MyBatisPlus-使用步骤

    MyBatisPlus-使用步骤 第一步 引入maven坐标依赖 <dependency> <groupId>com.baomidou</groupId> < ...

  8. 1.elasticsearch运行

    在docker中运行elasticsearch.kibana 一.MacOs 首先需要安装doceker,提供两种方式,选一种方便的就好 1.命令行安装方式 安装命令行 xcode-select -- ...

  9. 文心一言 VS 讯飞星火 VS chatgpt (37)-- 算法导论5.4 1题

    一.一个屋子里必须要有多少人,才能让某人和你生日相同的概率至少为1/2? 必须要有多少人,才能让至少两个人生日为 7月 4 日的概率大于 1/2? 文心一言: 一个屋子里必须要有多少人,才能让某人和你 ...

  10. 实例解析丨一文搞定GaussDB CM服务异常

    摘要:本文主要为大家带来如何处理GaussDB CM服务异常问题. 本文分享自华为云社区<[实例状态]GaussDB CM服务异常>,作者:酷哥. 首先确认是否是虚拟机.网络故障,底层故障 ...