题意:

给出一个序列a[1....n],a[i]代表在0....i-1中比a[i]小的个数。
求出这个序列。

思路:

1:暴力。
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
using namespace std;
const int maxn=8000+10;
int ans [maxn];
int a[maxn];
int vis[maxn];
int N;
int main ()
{
scanf("%d",&N);
for(int i=2;i<=N;i++)
scanf("%d",&a[i]); for(int i=N;i>=1;i--)//从最后往前遍历
{
int t=0,j;
for( j=1;j<=N;j++)//遍历1~ ~N;
{
if(!vis[j])
{
t++;
if(t==a[i]+1)
break;
}
}
ans[i]=j;
vis[j]=1;
}
for(int i=1;i<=N;i++)
printf("%d\n",ans[i]);
return 0;
}

POJ 2082Lost Cows<>的更多相关文章

  1. 树状数组 POJ 2481 Cows

    题目传送门 #include <cstdio> #include <cstring> #include <algorithm> using namespace st ...

  2. POJ 2481 Cows

    Cows Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 16546   Accepted: 5531 Description ...

  3. 2018.07.08 POJ 2481 Cows(线段树)

    Cows Time Limit: 3000MS Memory Limit: 65536K Description Farmer John's cows have discovered that the ...

  4. POJ 2481 Cows (线段树)

    Cows 题目:http://poj.org/problem?id=2481 题意:有N头牛,每仅仅牛有一个值[S,E],假设对于牛i和牛j来说,它们的值满足以下的条件则证明牛i比牛j强壮:Si &l ...

  5. POJ 2481 Cows(树状数组)

                                                                      Cows Time Limit: 3000MS   Memory L ...

  6. POJ 3348 - Cows 凸包面积

    求凸包面积.求结果后不用加绝对值,这是BBS()排序决定的. //Ps 熟练了template <class T>之后用起来真心方便= = //POJ 3348 //凸包面积 //1A 2 ...

  7. POJ 2186-Popular Cows (图论-强联通分量Korasaju算法)

    题目链接:http://poj.org/problem?id=2186 题目大意:有n头牛和m对关系, 每一对关系有两个数(a, b)代表a牛认为b牛是“受欢迎”的,且这种关系具有传递性, 如果a牛认 ...

  8. POJ 2481 Cows (数组数组求逆序对)

    题目链接:http://poj.org/problem?id=2481 给你n个区间,让你求每个区间被真包含的区间个数有多少,注意是真包含,所以要是两个区间的x y都相同就算0.(类似poj3067, ...

  9. POJ 3621Sightseeing Cows

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9851   Accepted: 3375 Description Farme ...

随机推荐

  1. HDU 3835 R(N)(枚举)

    题目链接 Problem Description We know that some positive integer x can be expressed as x=A^2+B^2(A,B are ...

  2. 字符串长度截取换行/n

    /// <summary>        /// 格式化字符串长度,超出部分显示省略号,区分汉字跟字母.汉字2个字节,字母数字一个字节        /// </summary> ...

  3. ural 1698. Square Country 5(记忆化搜索)

    1698. Square Country 5 Time limit: 2.0 secondMemory limit: 64 MB The first arithmetical operation ta ...

  4. js整频滚动展示效果(函数节流鼠标滚轮事件)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. yii2.0图片上传

    在根目录下夹uploads文件夹 控制器 UploadController.php <?php namespace frontend\controllers; use Yii; use fron ...

  6. 嵌套json

    今天一个客户问怎样把表中相同键值对应的文本按照一定顺序拼接起来.如果使用SQL实现将非常麻烦,并且效率低下.GP4.1以后提供了一个函数array_agg可以方便快捷,高效的实现该功能 比如原始查询是 ...

  7. C#生成word

    using Microsoft.Office.Interop.Word; using System; using System.Collections.Generic; using System.Co ...

  8. 1001. A+B Format

    Calculate a + b and output the sum in standard format -- that is, the digits must be separated into ...

  9. 解决ie阴影的兼容性

    box-shadow:0px 0px 10px #aba25b; -webkit-box-shadow:0px 0px 10px #aba25b; -moz-box-shadow:0px 0px 10 ...

  10. nmon命令用法

    用途 以交互方式显示本地系统统计信息并以记录方式记录系统统计信息. 语法 交互方式: nmon [ -h ] nmon [ -s < seconds > ] [ -c < count ...