cf1555C Coin Rows

题意:

有一个两行m列的地图,每个格子都有对应的价值,有a,b两个人,都从左上角到右下角,且都只能向右向下走,a先出发,a每到一个格子,就会获得这个地方的价值,然后b再出发,如果一个格子被a走过,b再走就不会获得价值
问b获得的最大价值

题解:

因为只能向右向下走,如果a从x位置向下走了,那么第一行x位置之后的a就拿不到,而第二行x位置之前的a也拿不到,而这些b可以选其一获得。取这两个部分的最大值

代码:

// Problem: C. Coin Rows
// Contest: Codeforces - Educational Codeforces Round 112 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1555/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Data:2021-08-16 23:55:41
// By Jozky#include <bits/stdc++.h>
#include <unordered_map>
#define debug(a, b) printf("%s = %d\n", a, b);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
clock_t startTime, endTime;
//Fe~Jozky
const ll INF_ll= 1e18;
const int INF_int= 0x3f3f3f3f;
template <typename T> inline void read(T& x)
{T f= 1;x= 0;char ch= getchar();while (0 == isdigit(ch)) {if (ch == '-')f= -1;ch= getchar();}while (0 != isdigit(ch))x= (x << 1) + (x << 3) + ch - '0', ch= getchar();x*= f;
}
template <typename T> inline void write(T x)
{if (x < 0) {x= ~(x - 1);putchar('-');}if (x > 9)write(x / 10);putchar(x % 10 + '0');
}
void rd_test()
{#ifdef LOCALstartTime= clock();freopen("in.txt", "r", stdin);
#endif
}
void Time_test()
{#ifdef LOCALendTime= clock();printf("\nRun Time:%lfs\n", (double)(endTime - startTime) / CLOCKS_PER_SEC);
#endif
}
const int maxn= 2e5 + 9;
int a[3][maxn];
int sum[3][maxn];
int main()
{//rd_test();int t;read(t);while (t--) {int n;cin >> n;for (int i= 1; i <= 2; i++) {for (int j= 1; j <= n; j++) {cin >> a[i][j];sum[i][j]= sum[i][j - 1] + a[i][j];}}int minn= INF_int;for (int i= 1; i <= n; i++) {int ans1= sum[1][n] - sum[1][i];int ans2= sum[2][i - 1];minn= min(minn, max(ans1, ans2));}cout << minn << endl;}//Time_test();
}

cf1555C Coin Rows相关推荐

  1. 1555C. Coin Rows

    C. Coin Rows:题目 题意:仿佛是一道难的dp,但是因为Alice先走,走完bob想要最大化收益. Alice走完后Bob要么一直往右走,要么一开始就下去然后往右走. #include &l ...

  2. Educational Codeforces Round 112 (Rated for Div. 2)

    Educational Codeforces Round 112 (Rated for Div. 2) 题号 题目 知识点 A PizzaForces B Two Tables C Coin Rows ...

  3. codeforces:ProblemMset

    最近一个月在codeforces上做的题(做个记录) 后面太多了就不把代码一一放出了,只放置了链接,可根据链接找到提交的代码. 最小子矩阵 #include <iostream> #inc ...

  4. Educational Codeforces Round 112 (Rated for Div. 2)(补题)

    B. Two Tables 题意: 给定一个W*H的矩形,在里面有一个蓝色桌子,坐标(左右顶点)(x1,y1)(x2,y2),然后还要在里面放一个红色桌子,要想放开红色桌子,问你蓝色桌子移动的最小距离 ...

  5. Educational Codeforces Round 112 (Rated for Div. 2) 个人题解

    A. PizzaForces 题意 有三种披萨制作方案:15分钟制作6片.20分钟制作8片和25分钟制作10片. 问制作出至少nnn片披萨要多少分钟 分析 三种方案的效率都一样,都是每分钟制作0.4个 ...

  6. html.textboxfor id,How to update the textbox value @Html.TextBoxFor(m = m.MvcGridModel.Rows[j].Id)

    问题 I have problem, that the text box value doesn't get updated with the new value in the model. @Htm ...

  7. pandas索引复合索引dataframe数据、索引其中一个水平(level)的所有数据行(index all rows in a level)

    pandas索引复合索引dataframe数据.索引其中一个水平(level)的所有数据行(index all rows in a level) 目录

  8. pandas基于dataframe字符串数据列不包含特定字符串来筛选dataframe中的数据行(rows where values do not contain substring)

    pandas基于dataframe字符串数据列不包含(not contains)特定字符串来筛选dataframe中的数据行(rows where values do not contain subs ...

  9. pandas使用groupby函数计算dataframe每个分组对应的数据行的个数(size of each group in dataframe, rows count of group)

    pandas使用groupby函数计算dataframe每个分组对应的数据行的个数(size of each group in dataframe, rows count of group) 目录

最新文章

  1. Tiled 瓦片地图
  2. 一起谈.NET技术,.NET异步编程:IO完成端口与BeginRead
  3. wordpress url index.php,WordPress对URL的路由解析过程详解
  4. 职称计算机考试有哪些题,职称计算机考试判断复习题「有答案」
  5. .net 引用Com组件的几种方案
  6. jquery 逗号分割截取字符串_经典面试题:分割回文串
  7. python 文本处理操作
  8. ubuntu下配置IP地址
  9. 《数字电路与逻辑设计》笔记及经典问答题
  10. python读取rtf文件_richtextbox怎样读取txt文件或rtf文件
  11. 人生,原来是个笑话?
  12. 仿QQ点赞吹泡泡效果
  13. 《算法竞赛入门经典》第三章思考题
  14. 《高等数学A》课堂笔记——高分必过
  15. 数字化技术加速人才转型 附下载
  16. 数据仓库ods层是啥意思_一文读懂大数据仓库建设
  17. 【学习笔记】Argus--H5游戏性能测试工具
  18. Xamarin iOS 让图片动起来,做一个简单的俄罗斯轮盘
  19. 星起航带你了解“短视频电商”带来巨大商机
  20. 内网靶场_从自做到拿下-攻击篇

热门文章

  1. 男人都应该懂的一张图。。 | 今日趣图
  2. echarts 时间曲线图_制作按时间每秒实时更新的echarts折线图
  3. kafka 怎么样连接图形化界面_图形化编程有多简单,点亮LED不到一分钟
  4. python3默认的代码编码是什么-Python3 到底什么是字符编码
  5. 阿里最新面试必备项之Java的String类,持续更新中!
  6. io python 读取pdf_Python读取PDF文件--pdfminer
  7. 硬件加速下webview切换闪屏_网页渲染性能优化 —— 性能优化下
  8. openkruise 缩容_Linus 本尊也来了!为什么 KubeCon 越来越火了?
  9. lunixs 常用命令c语言,常用Lunix命令 - osc_271igh42的个人空间 - OSCHINA - 中文开源技术交流社区...
  10. 10-4 5-4 查询至少生产三种不同速度PC的厂商 (20 分)