Codeforces Round #707 (Div. 2, based on Moscow Open Olympiad in Informatics Editorial
Codeforces Round #707 (Div. 2, based on Moscow Open Olympiad in Informatics)
Problem 1501A. Alexey and Train
按题意,比较到站的最大值.
using ll = long long;
int a[105], b[105], c[105];
int main() {
// ios_base::sync_with_stdio(false), cin.tie(0);
int _;
for (cin >> _; _--;) {
int n, s = 0;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
for (int i = 1; i <= n; i++) {
scanf("%d", &c[i]), s += a[i] - b[i - 1] + c[i];
if (i == n) break;
s = max(s + (b[i] - a[i] + 1) / 2, b[i]);
}
cout << s << "\n";
}
return 0;
}
Problem 1501B. Napoleon Cake
从后往前比较.
int arr[200001];
int res[200001];
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int _ = 1;
for (cin >> _; _--;) {
int n, i, mn = 1e9;
cin >> n;
for (i = 1; i <= n; i++) cin >> arr[i];
for (i = n; i >= 1; i--) {
mn = min(mn, i - arr[i]);
res[i] = (mn < i);
}
for (i = 1; i <= n; i++) cout << res[i] << " ";
cout << endl;
}
return 0;
}
Problem 1501C. Going Home
把两数之和想象成坐标,x 和 y
使用双指针然后存储和存储一下,如果能匹配并且 坐标不重复即可输出。
数组开大点,这个导致WA好几次了....
const int N = 5000003;
int x[N], y[N], a[N];
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 1; i <= n; ++i)
for (int j = i + 1; j <= n; ++j) {
int s = a[i] + a[j];
if (x[s] && y[s] && x[s] != i && y[s] != j && x[s] != j &&
y[s] != i) {
cout << "YES\n";
cout << i << " " << j << " " << x[s] << " " << y[s] << "\n";
return 0;
}
x[s] = i;
y[s] = j;
}
cout << "NO\n";
return 0;
}
Codeforces Round #707 (Div. 2, based on Moscow Open Olympiad in Informatics Editorial的更多相关文章
- Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics)
A. Even Subset Sum Problem 题意 给出一串数,找到其中的一些数使得他们的和为偶数 题解 水题,找到一个偶数或者两个奇数就好了 代码 #include<iostream& ...
- Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics)部分(A~E)题解
(A) Even Subset Sum Problem 题解:因为n非常非常小,直接暴力枚举所有区间即可. #include<bits/stdc++.h> using namespace ...
- Codeforces Round #680 (Div. 2, based on Moscow Team Olympiad)【ABCD】
比赛链接:https://codeforces.com/contest/1445 A. Array Rearrangment 题意 给定两个大小均为 \(n\) 的升序数组 \(a\) 和 \(b\) ...
- Codeforces Round #680 (Div. 2, based on Moscow Team Olympiad) D. Divide and Sum (思维,数学,逆元)
题意:有一个长度为\(2n\)数组,从中选分别选\(n\)个元素出来组成两个序列\(p\)和\(q\),(\(p\)和\(q\)中只要有任意一个元素在\(a\)的原位置不同,就算一个新的情况),选完后 ...
- Codeforces Round #680 (Div. 2, based on Moscow Team Olympiad) C. Division (数学)
题意:有两个数\(p\)和\(q\),找到一个最大的数\(x\),使得\(p\ mod\ x=0\)并且\(x\ mod\ q\ne 0\). 题解:首先,如果\(p\ mod\ q\ne0\),那么 ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...
- Codeforces Round #500 (Div. 2) [based on EJOI]
Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bit ...
- Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++ ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)
A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...
- (AB)Codeforces Round #528 (Div. 2, based on Technocup 2019 Elimination Round
A. Right-Left Cipher time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- 机密计算如何引领AI开发的安全未来
机密计算如何引领AI开发的安全未来 PrimiHub一款由密码学专家团队打造的开源隐私计算平台,专注于分享数据安全.密码学.联邦学习.同态加密等隐私计算领域的技术和内容. 先进的AI模型比如机器学习和 ...
- 使用CompletableFuture实现多个异步任务并行完成后合并结果
业务场景 需要同时从多个副本数据库中查询数据,并对查询结果进行合并去重处理后返回前端. 实现过程涉及多数据源切换,这里不作过多讨论. 编码实现 实现过程: 1.定义异步查询数据方法: 2.通过Comp ...
- 分享一个 asp.net core 多文件分块同时上传的组件
分享一个可多个文件同时上传.断点续传,并实时反馈上传进度的 Asp.Net core 组件. 服务器端 引用 nuget 包:JMS.FileUploader.AspNetCore 然后启用上传组件: ...
- 文心一言 VS 讯飞星火 VS chatgpt (156)-- 算法导论12.3 3题
三.用go语言,对于给定的 n 个数的集合,可以通过先构造包含这些数据的一棵二叉搜索树(反复使用TREE-INSERT 逐个插入这些数),然后按中序遍历输出这些数的方法,来对它们排序.这个排序算法的最 ...
- 15、string
1.string是什么? Go中的字符串是一个字节的切片,可以通过将其内容封装起在""中来创建字符串.Go中的的字符串是Unicode兼容的并且是UTF-8编码的. 2.strin ...
- 记录一些JDK的新特性~持续更新
1.record快速定义类 @Test public void testRecord() { /** * JDK16新特性 * * @param start * @param end */ recor ...
- MySQL运维12-Mycat分库分表之按天分片
一.按天分片 指定一个时间周期,将数据写入一个数据节点中,例如:第1-10天的数据,写入到第一个数据节点中,第2-20天的数据写入到第二个节点中,第3-30天的数据节点写入到第三个数据节点中. 说明1 ...
- 踩坑ffmpeg录制的mp4无法在浏览器上播放
前言 使用ffmpeg编译好的程序在电脑上进行音视频转换,可以参考这篇:<windows电脑FFmpeg安装教程手把手详解_windows安装ffmpeg>,而我们要做的是在游戏引擎中集成 ...
- pwd详解
linux下pwd 命令详解 Linux中用 pwd 命令来查看"当前工作目录"的完整路径. 简单得说,每当你在终端进行操作时,你都会有一个当前工作目录. 在不太确定当前位置时,就 ...
- MYSQL事务篇(高级篇)
1.事务介绍: 一般是指要做的或所做的事情. 在计算机 术语 中是指访问并可能更新数据库中各种 数据项 的一个程序 执行单元 (unit) 2.数据库事务具有ACID四大特性. ACID是以下4个词的 ...