Codeforces Round #832 (Div. 2) A~C题解
A
思路:这个题的话我们把负数和整数分别求出来,比较绝对值的大小,用较大的那个减去较小的那个就可以了。
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--)
{
int n;
cin >> n;
int zheng = 0, fu = 0;
for (int i = 1; i <= n; i++)
{
int x;
cin >> x;
if (x > 0)
zheng += x;
else
fu += x;
}
fu = abs(fu);
if (fu > zheng)
cout << fu - zheng << endl;
else
cout << zheng - fu << endl;
}
return 0;
}
B
思路:这个题一开始的时候想的是把全部的N放到前面,结果第二个测试点就WA了。其实这个题的正解是把全N和B换位置,但是有的N是不用动的,我们需要判断有几个N是不需要动的,要动的N的下标是从几开始。具体细节放在代码里。
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
void solve()
{
int n;
cin >> n;
if (n == 1)
{
cout << 1 << endl;
cout << 1 << ' ' << 3 << endl;
return ;
}
int k = n - n / 2;
cout << k << endl;
int j = 1;
for (int i = (n / 2 + 1) * 3; i <= 3 * n; i += 3)
{
cout << j << ' ' << i << endl;
j += 3;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--)
{
solve();
}
return 0;
}
C
思路:这个是个博弈的题,通过观察样例的话我们可以发现,我们想要让对手输的话,我们只需要一直把那个最小的数换给他,他只能把最小的那个数-1然后换出去,所以一直反复的话最小的那个数变成0的时候,那么那个人就输了。Alice是先手没所以只要第一个不是最小的那一个那么Alice就会赢反之Bob就会赢。如果第一个和后面的最小值相等的话还是Bob赢
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e6 + 10;
int a[N];
void solve()
{
int Min = 0x3f3f3f3f;
int n;
cin >> n;
int sum = 0;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
if (i >= 2)
Min = min(a[i], Min);
}
if (a[1] > Min)
{
cout << "Alice" << endl;
}
else
{
cout << "Bob" << endl;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--)
{
solve();
}
return 0;
}
Codeforces Round #832 (Div. 2) A~C题解的更多相关文章
- Codeforces Round #612 (Div. 2) 前四题题解
这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...
- Codeforces Round #198 (Div. 2)A,B题解
Codeforces Round #198 (Div. 2) 昨天看到奋斗群的群赛,好奇的去做了一下, 大概花了3个小时Ak,我大概可以退役了吧 那下面来稍微总结一下 A. The Wall Iahu ...
- Codeforces Round #672 (Div. 2) A - C1题解
[Codeforces Round #672 (Div. 2) A - C1 ] 题目链接# A. Cubes Sorting 思路: " If Wheatley needs more th ...
- Codeforces Round #614 (Div. 2) A-E简要题解
链接:https://codeforces.com/contest/1293 A. ConneR and the A.R.C. Markland-N 题意:略 思路:上下枚举1000次扫一遍,比较一下 ...
- Codeforces Round #610 (Div. 2) A-E简要题解
contest链接: https://codeforces.com/contest/1282 A. Temporarily unavailable 题意: 给一个区间L,R通有网络,有个点x,在x+r ...
- Codeforces Round #611 (Div. 3) A-F简要题解
contest链接:https://codeforces.com/contest/1283 A. Minutes Before the New Year 题意:给一个当前时间,输出离第二天差多少分钟 ...
- Codeforces Round #499 (Div. 2) D. Rocket题解
题目: http://codeforces.com/contest/1011/problem/D This is an interactive problem. Natasha is going to ...
- Codeforces Round #499 (Div. 2) C Fly题解
题目 http://codeforces.com/contest/1011/problem/C Natasha is going to fly on a rocket to Mars and retu ...
- Codeforces Round #198 (Div. 2)C,D题解
接着是C,D的题解 C. Tourist Problem Iahub is a big fan of tourists. He wants to become a tourist himself, s ...
随机推荐
- 【java】学习路径25-ArrayList类,Vector类,LinkedList类的使用和区别,Iterator迭代器的使用
ArrayList的使用 ArrayList类:可变化长度的数组. 与一般的数组不同的是,其长度不固定,可以添加任意类型的数据. 也可以添加不同类型的数据,但是一般不这么做. ArrayList类位于 ...
- iOS 集成WebRTC相关知识点总结
前言 本文主要是整理了使用WebRTC做音视频通讯时的各知识点及问题点.有理解不足和不到位的地方也欢迎指正. 对于你感兴趣的部分可以选择性观看. WebRTC的初始化 在使用WebRTC的库之前,需要 ...
- 高清地图转换(xord转apollo的bin文件)
目标 将carla中的OpenDrive地图(carla\Unreal\CarlaUE4\Content\Carla\Maps\OpenDrive)转换为Apollo中可识别的地图格式(bin与txt ...
- Web开发框架『express』的基本使用 —— { }
基本 res.send([body]) 和 res.end([data] [, encoding]) 的区别 1.参数的区别: res.send([body]): body这个参数可以是[Buffer ...
- JDK8中String的intern()方法详细解读【内存图解+多种例子+1.1w字长文】
写在前面,欢迎大家关注小编的微信公众号!!谢谢大家!! 一.前言 String字符串在我们日常开发中最常用的,当然还有他的两个兄弟StringBuilder和StringBuilder.他三个的区别也 ...
- dotnet7 aot编译实战
0 起因 这段日子看到dotnet7-rc1发布,我对NativeAot功能比较感兴趣,如果aot成功,这意味了我们的dotnet程序在防破解的上直接指数级提高.我随手使用asp.netcore-7. ...
- 五、frp内网穿透客户端frpc.ini各配置参数详解
[必须]标识头[common]是不可或缺的部分 [必须]frps服务端IPserver_addr = 0.0.0.00.0.0.0为FRP服务端IP,客户端要填写为服务端已配置的对应的IP,或者是服务 ...
- Elastic:Elastic Maps 基于位置的警报 - 7.10
文章转载自:https://elasticstack.blog.csdn.net/article/details/112535618
- Fluentd部署详解
Fluentd系统配置项 https://www.cnblogs.com/sanduzxcvbnm/p/13920972.html Fluentd自身日志 https://www.cnblogs.co ...
- 对vue中的data进行数据初始化
this.$data:是表示当前的改变后的this中的数据 this.$options.data():是表示没有赋值前的this中的数据,表示 初始化的data 一般可以使用Object.assign ...