他们改的题面太恶心惹不放了qaq放原题吧qaq
明明是最水的T1我爆了零??然后去肝最毒瘤的T2??宝贝你的脑子呢???
- 这个题我都不好意思说我怎么做的
- 就是枚举每一个时间, 算当前的牛跑到哪里了, 开桶记录
- 我还算有点*数, 这题的数据会让我的桶炸到九天之外(微笑 我就开始减每一轮的最小值(这样就都能保证非负了
- 对了我还memset了T遍我的桶(zz再见
正解
- 开一个last数组记录每头牛最终的位置, (long long) 然后从后往前枚举
- 如果前面的牛最终到达的比后面的牛远, 证明他肯定在过程中赶上了后面的牛, (起点严格递增), 归为一个组, 将前面的牛的坐标设为与后面的牛相同
- 否则, ans++
- ans初值应该为1
biu~
1 #include2 #include 3 #define ll long long 4 using namespace std; 5 ll last[100010]; 6 int n, t; 7 int main() { 8 scanf("%d%d", &n, &t); 9 for(int i = 1; i <= n; i++) {10 ll a, b;11 scanf("%lld%lld", &a, &b);12 last[i] = a+b*t;13 }14 int ans = 1;15 for(int i = n-1; i >= 1; i--) {16 if(last[i] >= last[i+1]) last[i] = last[i+1];17 else ans++;18 }19 cout< <