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的更多相关文章

  1. Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics)

    A. Even Subset Sum Problem 题意 给出一串数,找到其中的一些数使得他们的和为偶数 题解 水题,找到一个偶数或者两个奇数就好了 代码 #include<iostream& ...

  2. 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 ...

  3. Codeforces Round #680 (Div. 2, based on Moscow Team Olympiad)【ABCD】

    比赛链接:https://codeforces.com/contest/1445 A. Array Rearrangment 题意 给定两个大小均为 \(n\) 的升序数组 \(a\) 和 \(b\) ...

  4. Codeforces Round #680 (Div. 2, based on Moscow Team Olympiad) D. Divide and Sum (思维,数学,逆元)

    题意:有一个长度为\(2n\)数组,从中选分别选\(n\)个元素出来组成两个序列\(p\)和\(q\),(\(p\)和\(q\)中只要有任意一个元素在\(a\)的原位置不同,就算一个新的情况),选完后 ...

  5. 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\),那么 ...

  6. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)

    Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...

  7. Codeforces Round #500 (Div. 2) [based on EJOI]

    Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bit ...

  8. 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++ ...

  9. 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. 题解:很显然只有 \( ...

  10. (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 ...

随机推荐

  1. git 同时推送多个远程仓库

    今天遇到个git的问题:需要同时提交到两个远程仓库 解决方法: git add . git commit -m '提交信息' git remote -v git remote add old_orig ...

  2. SSPRQ码型设计

    serdes速率超过50G之后,在VSR光模块场景下SSPRQ使用较为广泛.SSPRQ用于PAM4光模块眼图压力,闭合率测试. 但是有很多serdes IP不支持此功能.出于测试需要需要新设计SSPR ...

  3. finally中的代码一定会执行吗?

    通常在面试中,只要是疑问句一般答案都是"否定"的,因为如果是"确定"和"正常"的,那面试官就没有必要再问了嘛,而今天这道题的答案也是符合这个 ...

  4. Scrapy框架爬取HTTP/2网站

    scrapy本身是自带支持HTTP2的爬取: https://docs.scrapy.org/en/latest/topics/settings.html?highlight=H2DownloadHa ...

  5. Arrarylist集合的使用

    前提:最近JAVA实训课老师讲了一些Arrarylist集合的相关知识,刚好端午假期有空就把这课上学到的知识和自己碰到的一些问题总结下来. 一.Arrarylist集合的使用(以学生信息存储作为演示) ...

  6. MinIO客户端之ping

    MinIO提供了一个命令行程序mc用于协助用户完成日常的维护.管理类工作. 官方资料 mc ping 检查指定的MinIO节点的服务是否可用. 不带参数,命令如下: ./mc ping local1 ...

  7. 使用gradle的方式进行Springboot3的web开发(微服务版)

    简要: 最近看了很多的Springboot3的项目,但是发现很多都是用maven来进行版本管理的,很少有用gradle来管理的,通过网上查找资料,看视频,终于自己写一个gradle管理的Springb ...

  8. weblogic GC overhead limit exceeded

    weblogic GC overhead limit exceeded 使用weblogic启动较大项目时,超出GC限制,可以通过修改 C:\Oracle\Middleware\Oracle_Home ...

  9. 【开源】EDUCN网站

    EDUCN https://scrc.rth1.link/ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN&q ...

  10. 文心一言 VS 讯飞星火 VS chatgpt (46)-- 算法导论6.1 4题

    四.假设一个最大堆的所有元素都不相同,那么该堆的最小元素应该位于哪里? 文心一言: 最大堆的最小元素位于堆的根结点.由于最大堆的性质,根结点是堆中所有元素的最大值,因此它也是堆中所有元素的最小值. 讯 ...