Codeforces Round #291 (Div. 2) D - R2D2 and Droid Army
来源:互联网 发布:ubuntu c语言调试工具 编辑:程序博客网 时间:2024/04/25 11:36
就是就最长的一段各位的最大之和不超过k。。。。用双指针和STL随便写写。。。
#include <iostream>#include <queue>#include <stack>#include <map>#include <set>#include <bitset>#include <cstdio>#include <algorithm>#include <cstring>#include <climits>#include <cstdlib>#include <cmath>#include <time.h>#define maxn 100005#define maxm 200005#define eps 1e-7#define mod 1000000007#define INF 0x3f3f3f3f#define PI (acos(-1.0))#define lowbit(x) (x&(-x))#define mp make_pair#define ls o<<1#define rs o<<1 | 1#define lson o<<1, L, mid #define rson o<<1 | 1, mid+1, R#define pii pair<int, int>#pragma comment(linker, "/STACK:16777216")typedef long long LL;typedef unsigned long long ULL;//typedef int LL;using namespace std;LL qpow(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base;base=base*base;b/=2;}return res;}LL powmod(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base%mod;base=base*base%mod;b/=2;}return res;}//headint a[maxn][5];multiset<int> s[5];multiset<int>::iterator it;int n, m, K;int res[10];void read(){scanf("%d%d%d", &n, &m, &K);for(int i = 0; i < n; i++)for(int j = 0; j < m; j++)scanf("%d", &a[i][j]);}void work(){int ans = 0;for(int i = 0, j = 0; i < n; i++) {int t = 0;for(int k = 0; k < m; k++) {s[k].insert(a[i][k]);t += *(--s[k].end());}while(j <= i && t > K) {for(int k = 0; k < m; k++) {it = s[k].find(a[j][k]);s[k].erase(it);}j++, t = 0;if(s[0].size() == 0) break;for(int k = 0; k < m; k++) t += *(--s[k].end());}if(ans < s[0].size()) {ans = s[0].size();for(int k = 0; k < m; k++) res[k] = *(--s[k].end());}}for(int k = 0; k < m; k++) printf("%d%c", res[k], k == m - 1 ? '\n' : ' ');}int main(){read();work();return 0;}
0 0
- Codeforces Round #291 (Div. 2)---D. R2D2 and Droid Army
- Codeforces Round #291 (Div. 2)D. R2D2 and Droid Army
- Codeforces Round #291 (Div. 2) D - R2D2 and Droid Army
- D. R2D2 and Droid Army 线段树+二分 Codeforces Round #291 (Div. 2)
- Codeforces Round #291 (Div. 2)D. R2D2 and Droid Army (线段树+二分)
- 线段树+二分(Codeforces Round #291 (Div. 2)D. R2D2 and Droid Army)
- Codeforces Round #291 (Div. 2)D.R2D2 and Droid Army——RMQ+二分
- RMQ -- ST算法 Codeforces Round #291 (Div. 2) D. R2D2 and Droid Army
- Codeforces Round #291 (Div. 2) D. R2D2 and Droid Army RMQ问题 ST算法
- Codeforces Round #291 (Div. 2) D. R2D2 and Droid Army RMQ/单调队列/尺取法
- Codeforces Round #291 (Div. 2) D R2D2 and Droid Army(线段树+二分)
- Codeforces Round #291 (Div. 2)-D. R2D2 and Droid Army(RMQ)
- Codeforces #291 (Div. 2) D. R2D2 and Droid Army(RMQ+二分)
- codeforces 514D R2D2 and Droid Army
- CodeForces 514D R2D2 and Droid Army
- CodeForces 514D-R2D2 and Droid Army
- R2D2 and Droid Army : CodeForces
- R2D2 and Droid Army - CodeForces 514 D 二分
- php用正则判断是否为数字
- iOS开发UI篇—使用picker View控件完成一个简单的选餐应用
- APKTOOL的使用心得
- android中HttpClient获取Session然后使用 WebView共享session的解决办法(转)
- Spring MVC3在controller和视图之间传递参数的方法
- Codeforces Round #291 (Div. 2) D - R2D2 and Droid Army
- 机器学习中的数学(2)-线性回归,偏差、方差权衡
- 用浏览器AXURE RP生成的文件网站,安装Axure-RP-Extension-for-Chrome
- 笔记:Java 对象与类
- IOS 内存二三事
- 图解Flex开发教程
- android里 什么时候用Thread 什么时候用service
- AndroidStudio自定义属性xmlns无法识别问题解决in Gradle projects,always use http://schemas.android.com/apk/res-auto
- RHEL7新旧命令对比表