第一次参加 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. .NET8极致性能优化CHRL

    前言 .NET8在.NET7的基础上进行了进一步的优化,比如CHRL(全称:CORINFO_HELP_RNGCHKFAIL)优化技术,CORINFO_HELP_RNGCHKFAIL是边界检查,在.NE ...

  2. BI到底是什么,是否所有企业都适合上BI?

    商业智能(Business Intelligence)的概念 商业智能(BI)是一种综合性的数据分析和决策支持系统,旨在帮助企业从海量的数据中提取有价值的信息,并将其转化为洞察力.报告和可视化呈现,以 ...

  3. 如何从Webpack迁移到Vite

    本文将介绍如何将前端web应用程序从 Webpack 升级到 Vite. Vite 是最新的前端开发工具,其受欢迎程度和采用率都在大幅增长.可以查看下图中来自 npm trends 的下载. 推动这一 ...

  4. [ABC281G] Farthest City

    Problem Statement You are given positive integers $N$ and $M$. Find the number, modulo $M$, of simpl ...

  5. 【Python微信机器人】第六七篇: 封装32位和64位Python hook框架实战打印微信日志

    目录修整 目前的系列目录(后面会根据实际情况变动): 在windows11上编译python 将python注入到其他进程并运行 注入Python并使用ctypes主动调用进程内的函数和读取内存结构体 ...

  6. 学透java自增(++)自减(--)运算符

    基本介绍 自增(++)和自减(--)运算符是对变量在原始值的基础上进行加1或减1的操作. 它们都有前缀和后缀两种形式. 前缀就是++在前面,后缀就是++在后面 前缀先自增(减),后缀后自增(减) 前缀 ...

  7. TypeScript核心基础

    前言 为了方便我们直接使用脚手架让他帮我们直接编译就完事了 创建一个 Vue 应用 前提条件 熟悉命令行 已安装 16.0 或更高版本的 Node.js npm init vue@latest 这一指 ...

  8. Windows Server 2016配置NTP客户端

    前提:开通Windows Time 服务 输入services.msc进入服务管理界面,找到Windows Time 开启服务. 情况1:可以直接设置NTP时钟 控制面板--时钟和区域--设置时间和日 ...

  9. 零代码搭建一个微信小程序

    本文分享自华为云社区<[新手指引]体验通过Astro Zero零代码快速搭建微信小程序>,作者:华为云Astro . 您将学会如何基于Astro零代码能力,DIY开发,完成问卷.投票.信息 ...

  10. 【华为云技术分享】DLI跨源|当DLI遇见MongoDB

    导语: MongoDB作为灵活高效易扩展的no-schema数据库,越来越受到互联网公司.游戏行业等开发者的青睐,但是MongoDB有着独特的语言接口,并不能很好满足数据分析师构建数据治理应用的需求, ...