<每日一题> Day2:CodeForces-1141C.PolycarpRestoresPermutation(思维题)
参考代码:
#include <iostream>
#include <cstring>
using namespace std; const int maxn = + , INF = 0x3f3f3f3f;
int value[maxn], ans[maxn];
bool vis[maxn], flag; int main() {
int n;
cin >> n;
flag = true;
memset(vis, false, sizeof vis);
for(int i = ; i < n - ; i ++) cin >> value[i];
ans[] = ;
int Min = INF;
for(int i = ; i < n - ; i ++) {
ans[i + ] = ans[i] + value[i];
}
for(int i = ; i < n; i ++)
Min = min(Min, ans[i]); for(int i = ; i < n; i ++) {
ans[i] += - Min;
if(ans[i] > && ans[i] < maxn)
vis[ans[i]] = true;
}
for(int i = ; i <= n; i ++)
if(!vis[i]) flag = false;
if(!flag) cout << -;
else {
for(int i = ; i < n; i ++) cout << ans[i] << ' ';
}
cout << endl;
return ;
}
<每日一题> Day2:CodeForces-1141C.PolycarpRestoresPermutation(思维题)的更多相关文章
- CodeForces - 631C ——(思维题)
Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...
- CodeForces - 1102A(思维题)
https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...
- <每日一题> Day1:CodeForces.1140D.MinimumTriangulation(思维题)
题目链接 参考代码: #include <iostream> using namespace std; int main() { ; int n; cin >> n; ; i ...
- Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)
A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces 1038D - Slime - [思维题][DP]
题目链接:http://codeforces.com/problemset/problem/1038/D 题意: 给出 $n$ 个史莱姆,每个史莱姆有一个价值 $a[i]$,一个史莱姆可以吃掉相邻的史 ...
- CodeForces - 468A ——(思维题)
Little X used to play a card game called "24 Game", but recently he has found it too easy. ...
- CodeForces - 669D——(思维题)
Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced b ...
- CodeForces - 589D —(思维题)
Welcoming autumn evening is the best for walking along the boulevard and npeople decided to do so. T ...
- Sonya and Robots CodeForces - 1004C (思维题)
Sonya and Robots time limit per test 1 second memory limit per test 256 megabytes input: standard in ...
随机推荐
- GUI学习之十三——QPlainTextEdit学习总结
QPlainTextEdit可以说是一个简化版的QTextEdit类控件,和QTextEdit的功能差不多,使用了QTextEdit和QTextDocument作为背后实现的技术支撑. 由于QPlai ...
- impala常用语法
参考:https://www.w3cschool.cn/impala/impala_alter_table.html
- Netty学习第三章 Linux网络编程使用的I/O模型
一.同步阻塞IO:blocking IO(BIO) 1.过程分析: 当进程进行系统调用时,内核就会去准备数据,当数据准备好后就复制数据到内核缓冲器,复制完成后将数据拷贝到用户进程内存,整个过程都是阻塞 ...
- Django【第4篇】:Django之模板继承
jango框架之模板继承和静态文件配置 一.模板继承 目的是:减少代码的冗余 语法: {% block classinfo %} {% endblock %} 具体步骤: 1.创建一个base.htm ...
- nodejs第一天
按下node进入交互模式 ,按两次ctrl + c 退出 或者输.exit退出
- A1046
n个节点围成一个环,每个节点之间的距离已知.输入n并给出n个节点的距离,输入m组节点编号(两个),求这两个节点编号间的最短距离. 1 建立dis[]数组,记录V1点到每一个点的顺时针距离,sum计算环 ...
- React native 平时积累笔记
常用插件: react-native-check-box 复选框react-native-sortable-listview 列表拖拽排序 react-native-doc-viewer 预览组件 r ...
- [luogu]P3941 入阵曲[前缀和][压行]
[luogu]P3941 入阵曲 题目描述 小 F 很喜欢数学,但是到了高中以后数学总是考不好. 有一天,他在数学课上发起了呆:他想起了过去的一年.一年前,当他初识算法竞赛的 时候,觉得整个世界都焕然 ...
- codeforces D Salary Changing
题意:给你n个人,和s块钱,每个人都有一个工资区间,你给所有人都发工资.然后要他们工资的中位数最大. 思路:二分找那个值.那个值要满足至少有n/2+1个工资区间内. #include<cstdi ...
- Understanding RequireJS for Effective JavaScript Module Loading
Modular programming is used to break large applications into smaller blocks of manageable code. Modu ...