IOI2011 BZOJ2600 ricehub
生活随笔
收集整理的這篇文章主要介紹了
IOI2011 BZOJ2600 ricehub
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
BZOJ
分析
直接用兩個(gè)指針掃,中位數(shù)就是放米倉(cāng)的位置。
代碼
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;template <typename T> inline void read(T &x) {T f = 1; x = 0; char c;for (c = getchar(); !isdigit(c); c = getchar()) if (c == '-') f = -1;for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);x *= f;
}int R, ans;
ll L, B, sum;
ll x[100005];int main() {read(R), read(L), read(B);for (int i = 1; i <= R; ++i) read(x[i]);for (int i = 1, j = 1; j <= R; ++j) {sum += x[j] - x[i+j>>1];while (sum > B) {i++;sum -= x[i+j>>1] - x[i-1];}if (ans < j - i + 1) ans = j - i + 1;}printf("%d", ans);return 0;
}
轉(zhuǎn)載于:https://www.cnblogs.com/hlw1/p/11437384.html
總結(jié)
以上是生活随笔為你收集整理的IOI2011 BZOJ2600 ricehub的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: NOIP2013 华容道
- 下一篇: JLOI2011 飞行路线