BZOJ 3893 Usaco2014 Dec Cow Jog 模拟
2015-02-27 18:24
357 查看
题目大意:给出n头牛他们的初始位置和各自的速度,一头牛追上另一头牛之后这两头牛会变成一头牛,问最后剩下几头牛。
思路:简单模拟一下不难发现,我们只要算出如果正常行驶每头牛的最后到达的地点,从后往前扫一下,有多少个单调不减的序列就是最后有多少头牛。
CODE:
思路:简单模拟一下不难发现,我们只要算出如果正常行驶每头牛的最后到达的地点,从后往前扫一下,有多少个单调不减的序列就是最后有多少头牛。
CODE:
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define MAX 100010 #define INF 1e18 using namespace std; int cnt; long long x,y,t,src[MAX]; int main() { cin >> cnt >> t; for(int i = 1; i <= cnt; ++i) { scanf("%lld%lld",&x,&y); src[i] = x + y * t; } int ans = 0; long long last = INF; for(int i = cnt; i; --i) if(src[i] < last) { last = src[i]; ++ans; } cout << ans << endl; return 0; }
相关文章推荐
- bzoj 3826: [Usaco2014 Dec]Cow Jog LIS
- 【BZOJ3893】【Usaco2014 Dec】金组 Runing Cow
- Bzoj3893 [Usaco2014 Dec]Cow Jog
- [bzoj3893][Usaco2014 Dec]Cow Jog_暴力
- 【BZOJ3893】【Usaco2014 Dec】Cow Jog 乱搞
- BZOJ 3893 [Usaco2014 Dec]Cow Jog
- bzoj3893【Usaco2014 Dec】Cow Jog
- BZOJ 3893 [Usaco2014 Dec]Cow Jog
- bzoj 3893: [Usaco2014 Dec]Cow Jog 并查集+单调队列
- BZOJ 3892 Usaco2014 Dec Marathon DP
- BZOJ 1648 USACO 2006 Dec Cow Picnic 奶牛野餐 搜索
- bzoj 3892: [Usaco2014 Dec]Marathon 动态规划
- BZOJ3476 [Usaco2014 Mar]The Lazy Cow
- bzoj1649: [Usaco2006 Dec]Cow Roller Coaster
- BZOJ 3891 USACO 2014 Dec Piggy Back 搜索 最短路
- bzoj 1649: [Usaco2006 Dec]Cow Roller Coaster 背包dp
- bzoj 3825: [Usaco2014 Dec]Marathon
- bzoj1649 [Usaco2006 Dec]Cow Roller Coaster
- BZOJ 3891 Usaco2014 Dec Piggy Back BFS
- bzoj 1649: [Usaco2006 Dec]Cow Roller Coaster(DP)