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 ...
随机推荐
- 详细一些的vue生命周期
如果你和我一样,以前对vue生命周期的理解仅限于生命周期钩子,那么本文可以让我们更深入一层,理解vue在生命周期各个阶段所做的事,对我们对vue的理解和使用很有好处. (1)通过new Vue()创建 ...
- python数据类型元组、列表、集合、字典相互嵌套
系统 Windows 10 专业工作站版22H2 软件 python-3.9.6-amd64.exe 拓展库: jupyter==1.0.0 notebook==7.0.6 1.元组嵌套 1.1 元组 ...
- 使用 FastEndpoints 来垂直切换Web API的控制器方法
在我们开发项目的Web API的时候,随着项目功能要求越来越多,可能我们会为控制器基类增加越来越多的基础功能,有些功能有一定的适应性,但可能在一般的子类中用不到,而随着对控制器控制要求越来越精细,那么 ...
- ElasticSearch之Exists API
检查指定名称的索引是否存在. 命令样例如下: curl -I "https://localhost:9200/testindex_002?pretty" --cacert $ES_ ...
- Java 全栈知识体系(2021 PDF 版本)
40000 +字长文总结,民工哥已将此文整理成PDF文档了,需要的见文后下载获取方式. 全栈知识体系总览 Java入门与进阶 面向对象与Java基础 Java 基础 - 面向对象 Java 基础 - ...
- STM32CubeMX教程8 TIM 通用定时器 - 输出比较
1.准备材料 开发板(STM32F407G-DISC1) ST-LINK/V2驱动 STM32CubeMX软件(Version 6.10.0) keil µVision5 IDE(MDK-Arm) 逻 ...
- libGDX游戏开发之Sprite、Texture和TextureRegion绘制旋转、反转(九)
libGDX游戏开发之Sprite.Texture和TextureRegion绘制反转(九) libGDX系列,游戏开发有unity3D巴拉巴拉的,为啥还用java开发?因为我是Java程序员emm- ...
- P6357 题解
Luogu 题面 题目描述 给定一串长度为 \(n\) 的数字,数字为 \(0 \sim 9\) 之间的任意一个,下标从 \(1\) 记起. 然后进行 \(m\) 次区间查询,每次查找区间 \([l, ...
- k8s卷管理-1
目录 卷管理-1 1. 本地存储 1.1 emptyDir 1.2 hostPath 网络存储 搭建NFS服务器 使用NFS网络存储 搭建iSCSI服务器 使用iSCSI网络存储 卷管理-1 我们之前 ...
- Guava常用工具类总结
=== -"我想写得更优雅,可是没人告诉我怎么写得更优雅" -"Null的含糊语义让人很不舒服.Null很少可以明确地表示某种语义,例如,Map.get(key)返回Nu ...