题意:

给出一个序列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_5821_Ball(贪心)

    题目链接:hdu_5821_Ball 题意: 给你序列A和序列B,依次给你m个区间,每次你可以交换区间内的任意数,问最后能不能将A变成B 题解: 比赛当时没想到,智商被压制 1001: 假设有4个红球 ...

  2. OpenCV2.x自学笔记——固定阈值

    threshold( const CvArr* src,  CvArr* dst,  double threshold,  double max_value,  int threshold_type) ...

  3. Python之线程&进程

    线程: 线程是操作系统能够进行运算调度的最小单位.它被包含在进程之中,是进程中的实际运作单位.一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行不同的任务. thr ...

  4. thrift安装笔记

    Thrift源于大名鼎鼎的facebook之手,在2007年facebook提交Apache基金会将Thrift作为一个开源项目,对于当时 的facebook来说创造thrift是为了解决facebo ...

  5. Openjudge-计算概论(A)-球弹跳高度的计算

    描述: 一球从某一高度落下(整数,单位米),每次落地后反跳回原来高度的一半,再落下.编程计算气球在第10次落地时,共经过多少米? 第10次反弹多高?输入输入一个整数h,表示球的初始高度.输出输出包含两 ...

  6. PHP class which generates PDF files from UTF-8 encoded HTML

    http://www.mpdf1.com/mpdf/index.php

  7. C#整理 条件语句

    条件语句主要分为if else语句和switch case语句. if else语句主要分为四种格式: 1. if(表达式) {} 2.二选一 if(表达式) {} else {} 3.多选一 if( ...

  8. vs中的各种快捷键

    1. VS注释与取消注释快捷键 CTRL + K , CTRL + C(注释) CTRL + K , CTRL + U(取消注释)

  9. jquery ui sortable 实现table,row的拖动。(Make Table Rows Sortable Using jQuery UI Sortable)

    // Return a helper with preserved width of cells var fixHelper = function(e, ui) { //console.log(ui) ...

  10. PeekMessage与GetMessage的对比

    PeekMessage与GetMessage的对比相同点:PeekMessage函数与GetMessage函数都用于查看应用程序消息队列,有消息时将队列中 的消息派发出去. 不同点:无论应用程序消息队 ...