<每日一题> 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 ...
随机推荐
- python类和self解析
在介绍Python的self用法之前,先来介绍下Python中的类和实例……我们知道,面向对象最重要的概念就是类(class)和实例(instance),类是抽象的模板,比如学生这个抽象的事物,可以用 ...
- css3-文字与字体
1. 给文字添加阴影---text-shadow 语法: text-shadow: X-Offset Y-Offset blur color; X-Offset:表示阴影的水平偏移距离,其值为正值时阴 ...
- Oracle RAC业务bug导致部分数据丢失处理
问题描述:业务部门在10月26日发现某张基础表中丢失部分数据,系为9月份录入系统的基础数据丢失 Oracle RAC环境做的RMAN备份,10月18日做过expdp数据泵备份,丢失数据表名为T_GL_ ...
- layui jquery ajax,url,type,async,dataType,data
$.ajax({ url: '/foensys/user/userDelete/'+data[0].id, type:"get", async:true, dataType:&qu ...
- Python pdfkit
序言 住在地下室的人,依然有仰望星空的权利. pdfkit python使用pdfkit中,如果使用pdfkit.fromurl 或者pdfkit.fromstring等,就会出现上述错误.而且如果你 ...
- Windows上安装Apache
1.下载 (1)进入Apache官网http://httpd.apache.org— (2)点击Download (3)点击Files for Microsoft Windows (4)点击Apach ...
- MapServer教程3
Compiling on Unix Compiling on Win32 PHP MapScript Installation .NET MapScript Compilation IIS Setup ...
- AT2370 Piling Up
https://www.luogu.org/jump/atcoder/2370 题解 答案不是\(2^{2m}\)因为每轮的第一次取球可能会不够. 我们可以设\(dp[i][j]\)表示到了第\(i\ ...
- Sign on Fence(连续的长为W的一段中最小的数字的最大值)
题目链接:http://codeforces.com/problemset/problem/484/E 题意:给你个n,n个木板都有高度,宽度都为1 ,给你两个数[l,r]和一个w,求在[l,r]区间 ...
- Oracle--利用监听器日志监控访问该数据库的客户端IP
服务器10.10.10.168 数据库seineebs 客户端 10.10.10.14 用户guipeng.zhang 查看监听器状态: 在本机利用PL/SQL工具连接该数据库 查看监听器日志:一 ...