3314: [Usaco2013 Nov]Crowded Cows Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 86 Solved: 61[Submit][Status] Description Farmer John's N cows (1 <= N <= 50,000) are grazing along a one-dimensional fence. Cow i is standing at location x(i) and has…
3314: [Usaco2013 Nov]Crowded Cows Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 111 Solved: 79[Submit][Status][Discuss] Description Farmer John's N cows (1 <= N <= 50,000) are grazing along a one-dimensional fence. Cow i is standing at location x(…
第一次写单调队列太垃圾... 左右各扫一遍即可. #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…
正反两遍个来一次单调队列 DP 即可. Code: #include<cstdio> #include<deque> #include<algorithm> using namespace std; const int maxn = 50000+3; int mark[maxn]; struct Node{ long long pos,height; Node(long long pos=0,long long height=0):pos(pos),height(hei…
3315: [Usaco2013 Nov]Pogo-Cow Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 143 Solved: 79[Submit][Status] Description In an ill-conceived attempt to enhance the mobility of his prize cow Bessie, Farmer John has attached a pogo stick to each of Bes…
3016: [Usaco2012 Nov]Clumsy Cows Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 71 Solved: 52[Submit][Status] Description Bessie the cow is trying to type a balanced string of parentheses into her new laptop, but she is sufficiently clumsy (due to h…
树形dp..水 ------------------------------------------------------------------------ #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #define rep( i , n ) for( int i = 0 ; i < n ; i++ ) #define clr( x , c…