原题链接

参考代码:

#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(思维题)的更多相关文章

  1. CodeForces - 631C ——(思维题)

    Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...

  2. CodeForces - 1102A(思维题)

    https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...

  3. <每日一题> Day1:CodeForces.1140D.MinimumTriangulation(思维题)

    题目链接 参考代码: #include <iostream> using namespace std; int main() { ; int n; cin >> n; ; i ...

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

  5. Codeforces 1038D - Slime - [思维题][DP]

    题目链接:http://codeforces.com/problemset/problem/1038/D 题意: 给出 $n$ 个史莱姆,每个史莱姆有一个价值 $a[i]$,一个史莱姆可以吃掉相邻的史 ...

  6. CodeForces - 468A ——(思维题)

    Little X used to play a card game called "24 Game", but recently he has found it too easy. ...

  7. CodeForces - 669D——(思维题)

    Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced b ...

  8. CodeForces - 589D —(思维题)

    Welcoming autumn evening is the best for walking along the boulevard and npeople decided to do so. T ...

  9. Sonya and Robots CodeForces - 1004C (思维题)

    Sonya and Robots time limit per test 1 second memory limit per test 256 megabytes input: standard in ...

随机推荐

  1. Spark--wordcount(词频降序)

    import org.apache.spark.{SparkConf, SparkContext} object wc2 { def main(args: Array[String]): Unit = ...

  2. Cloneable接口的作用与深度克隆与浅度克隆

    cloneable接口的作用 cloneable其实就是一个标记接口,只有实现这个接口后,然后在类中重写Object中的clone方法,然后通过类调用clone方法才能克隆成功,如果不实现这个接口,则 ...

  3. HRESULT: 0x80040228

    When run the arcgis engine codes in the console application, may come to the exception: HRESULT: 0x8 ...

  4. Spring boot @Transactional

    1.注解@Transactional 2.异常回滚 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); @Ov ...

  5. [517]Kite 题解

    前言 今天又是爆零的一天. 被同学坑了,还以为四边形的点是按任意序给定的,然后打了一个特别复杂的矩形判断QAQ. 题意简述 按顺序给定一个四边形,求有多少个点在这个四边形的对称轴上. 题解 分情况讨论 ...

  6. 【bzoj4551】[Tjoi2016&Heoi2016]树

    *题目描述: 在2016年,佳媛姐姐刚刚学习了树,非常开心.现在他想解决这样一个问题:给定一颗有根树(根为1),有以下 两种操作:1. 标记操作:对某个结点打上标记(在最开始,只有结点1有标记,其他结 ...

  7. 特征点检测算法——FAST角点

    上面的算法如SIFT.SURF提取到的特征也是非常优秀(有较强的不变性),但是时间消耗依然很大,而在一个系统中,特征提取仅仅是一部分,还要进行诸如配准.提纯.融合等后续算法.这使得实时性不好,降系了统 ...

  8. Model 层

    package com.test.mvp.mvpdemo.mvp.v1.model; import com.test.mvp.mvpdemo.mvp.v1.MainContract; import o ...

  9. 《SQL Server 2012 T-SQL基础》读书笔记 - 6.集合运算

    Chapter 6 Set Operators 语法如下: Input Query1 <set_operator> Input Query2 [ORDER BY ...] 有ORDER B ...

  10. HDU 5073 Galaxy (数学)

    Galaxy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Su ...