Lost Cows POJ 2182 思维+巧法】的更多相关文章

Lost Cows POJ 2182 思维 题意 是说有n头牛,它们身高不一但是排成了一队,从左到右编号为1到n,现在告诉你从第二号开始前面的那些牛中身高小于它的个数,一共有n-1个数.然后求出它们按照身高来排序的话从低到高编号会是多少. 解题思路 首先我们需要从它给的数据逆序来进行处理,为什么,比如倒数第一个数据是0的话,说明前面没有比它矮的牛,那么它的编号就是1,然后倒数第二个是2的话,就是说前面有两个比它矮,因为1号已经有了,所以他就是4号,后面以此类推. 根据这个思路我们就可以进行模拟(…
这题实在不知道起啥名好了 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 懒得想背景故事了,开门见山. 有一个长度为n的整数数列A0,A1,A2....An-1.从中找出两个整数Ai和Aj,Ai在Aj的前面,即i<j,使得Ai-Aj尽可能的大.请输出可能的最大的Ai-Aj的值. 输入  多组输入.每一组测试数据的第一行是一个整数n,然后第二行是n个整数,第i个数 表示Ai.(测试数据组数<=20,2<=n<=10…
Code: #include<cstdio> #include<stack> #include<cstring> #include<algorithm> using namespace std; const int maxn = 100000 + 233; int n, C[maxn], height[maxn]; stack<int>S; inline int lowbit(int t) { return t & (-t);} inli…
POJ 2182 暴力 /* 题意: 一个带有权值[1,n]的序列,给出每个数的前面比该数小的数的个数,当然比一个数前面比第一个数小的个数是0,省略不写,求真正的序列.(拗口) 首先想到的是从前到后暴力枚举暴力枚举.数据量为8000,O(n^2). */ #include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> #incl…
Buy Tickets POJ - 2828 思维+线段树 题意 是说有n个人买票,但是呢这n个人都会去插队,问最后的队列是什么情况.插队的输入是两个数,第一个是前面有多少人,第二个是这个人的编号,最后输出编号就好了. 解题思路 这个题要倒着处理,因为最后一个人插队完成后,别人就不能影响他了.他前面有n个人,那么他就是n+1号位置上,这样来的话,我们只需要知道那个位置,他前面有n个人就行.默认每个位置都没有人. 详细看代码. 代码实现 #include<cstdio> #include<…
题目链接:http://poj.org/problem?id=2182 Lost Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12736   Accepted: 8168 Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, t…
主题链接:http://poj.org/problem? id=2182 Lost Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9152   Accepted: 5879 Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, t…
Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, they visited the neighborhood 'watering hole' and drank a few too many beers before dinner. When it was time to line up for their e…
[题目链接] http://poj.org/problem?id=2182 [算法] 树状数组 + 二分 [代码] #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #…
Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10996   Accepted: 7059 Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, they visited the neighborhood 'watering hole' a…