Educational Codeforces Round 30C-模拟&贪心-Strange Game On Matrix
来源:互联网 发布:淘宝的退款率怎么看 编辑:程序博客网 时间:2024/06/03 16:21
http://codeforces.com/contest/873/problem/C
其实叫贪心有些牵强。这种题就是重在思维。
统计一个前缀和就好了。然后找到再每列中找到最大结果,把他们的结果加起来,并且把他们之前的1当作结果来求就行。。
感觉题意有点乱。。
如果是花费要求最小最重要,那么每一个多得到第一个为1的地方结束。
如果是获得最大。那么那么就全部好了。
#include <bits/stdc++.h>/* 模拟。*/using namespace std;const int maxn=120;int a[maxn][maxn];int sum[maxn][maxn];int m,n,k;int main(){ while(~scanf("%d%d%d",&m,&n,&k)){ memset(sum,0,sizeof(sum)); for(int i=1;i<=m;i++){ for(int j=1;j<=n;j++){ scanf("%d",&a[i][j]); sum[j][i]=a[i][j]+sum[j][i-1]; } } int hav=0; int cos=0; int ans; for(int i=1;i<=n;i++){ ans=0; int loc=1; for(int j=1;j<=m;j++){ int len=min(k,m-j+1); if(j+len-1>m) continue; int all=sum[i][j+len-1]-sum[i][j-1]; if(ans<all){ loc=j; ans=all; } } if(loc!=1) cos+=sum[i][loc-1]; hav+=ans; } printf("%d %d\n",hav,cos); } return 0;}
阅读全文
0 0
- Educational Codeforces Round 30C-模拟&贪心-Strange Game On Matrix
- Educational Codeforces Round 30 C. Strange Game On Matrix
- Codeforces 873C Strange Game On Matrix【贪心】水题
- codeforces 873 C. Strange Game On Matrix【贪心】
- (Coderforces 873C)C. Strange Game On Matrix 贪心+模拟
- Educational Codeforces Round 22-C. The Tag Game-搜索,贪心
- Educational Codeforces Round 12(C)贪心
- codeforces——873C —— Strange Game On Matrix
- Codeforces-Strange Game On Matrix(暴力直接写)
- Educational Codeforces Round 7-C. Not Equal on a Segment(模拟)
- Codeforces Educational Codeforces Round 3 C. Load Balancing(贪心)
- Educational Codeforces Round 1 B.Queries on a String(模拟)
- Codeforces - Educational Codeforces Round 14C - Exponential notation(模拟)
- Educational Codeforces Round 22 C. The Tag Game dfs
- Educational Codeforces Round 22 C. The Tag Game(思维)
- Educational Codeforces Round 22 C. The Tag Game 搜索
- Educational Codeforces Round 2C. Make Palindrome(贪心构造)
- Educational Codeforces Round 2 C.Make Palindrome(贪心)
- struts-config.xml配置文件的scope
- web service错误Use @XmlType.name and @XmlType.namespace to assign different names to them.
- 如何用低廉的成本高效提高事务吞吐量
- Replugin插件化框架简要分析
- 2-2 Time类的定义
- Educational Codeforces Round 30C-模拟&贪心-Strange Game On Matrix
- Android : 隐藏软键盘
- Eric6与pyqt5学习笔记 2【页面基本布局】
- 【安全牛学习笔记】windows系统域和工作组的区别
- Hadoop之MapReduce
- MySQL分库分表总结参考
- 二维数组的查找
- 比较时间
- java设计模式之一:普通工厂模式