B. Psychos in a Line Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/319/B Description There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who h…
D. Psychos in a Line time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho…
维护一个单调下降的队列. 对于每一个人,只需要找到在他前面且离他最近的可以杀掉他的人即可. #include <cstdio> #include <vector> #include <algorithm> #include <cstring> using namespace std; #define N 100005 vector<int> v; int f[N], n, t, cnt; int main() { scanf("%d&q…
There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill…
双端队列deque容器: 关于deque最常用的有这几个函数: 都是成员函数 双端队列模板题:[洛谷]P2952 [USACO09OPEN]牛线Cow Line #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<deque> using namespace std; int n, cnt; deque<int> q; i…
Psychos in a Line CodeForces - 319B There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the…
Description Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't e…
第一次写单调队列太垃圾... 左右各扫一遍即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define N 50010 using namespace std; struct data { int x,h; }a[N],q[N]; int n,m,l,r; int ok1[N],ok2[N]; inline int read() { ,ans…
Trade Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3401 Appoint description:  Description Recently, lxhgww is addicted to stock, he finds some regular patterns after a few days' study.  He fo…
Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5809    Accepted Submission(s): 1911 Problem Description There is a sequence of integers. Your task is to find the longest subsequenc…