<每日一题> 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 ...
随机推荐
- babel 转换箭头函数
转换前: const sum = (a,b)=>a+b 转化后: // "use strict"; // var fn = function fn(a, b) { // re ...
- php sockets扩展安装
php sockets扩展安装 今天安装cacti发现需要php sockets扩展,而现在的lnmp没有安装,于是想到了phpzie工具安装扩展,安装方法如下: cd php-5.3.8/ext ...
- HDU-6278-Jsut$h$-index(主席树)
链接: https://vjudge.net/problem/HDU-6278 题意: The h-index of an author is the largest h where he has a ...
- 手把手搭建K3cloud插件开发环境
最近几天在配置K3cloud开发环境,发现不论是产品论坛还是百度出来的结果,都不够满意,很多大咖给提供的环境搭建手册都是那个云山雾罩的PPT 也就是这个open.kingdee.com/K3Cloud ...
- Oracle的分页和MySQL的分页
Oracle的分页: select * from ( select rownum r,a from tabName where rownum <= 20 ) where r > 10 使用 ...
- ASP.net 能写一个上传整个文件夹的东东
IE的自带下载功能中没有断点续传功能,要实现断点续传功能,需要用到HTTP协议中鲜为人知的几个响应头和请求头. 一. 两个必要响应头Accept-Ranges.ETag 客户端每次提交下载请求时,服务 ...
- POJ 1161 Walls ( Floyd && 建图 )
题意 : 在某国,城市之间建起了长城,每一条长城连接两座城市.每条长城互不相交.因此,从一个区域到另一个区域,需要经过一些城镇或者穿过一些长城.任意两个城市A和B之间最多只有一条长城,一端在A城市, ...
- Apache主要配置文件http.conf
1.基本概念 Define SRVROOT "/Apache24" ServerRoot "${SRVROOT}" #Apache安装的根路径 #Listen ...
- Move Controller UE4键位
工作中需要,就总结了一下,如下图:
- iOS-Swizzle
最后更新:2017-06-21 一.先说结论 void swizzleMethod(Class cls, SEL originalSelector, SEL swizzledSelector) { M ...