博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【贪心】[luoguP1650]赛马
阅读量:4347 次
发布时间:2019-06-07

本文共 1418 字,大约阅读时间需要 4 分钟。

我不会动态规划

核心思想小换大 大吃大 大不能吃小 要吃的有价值

代码如下

#include
#include
#include
#include
using namespace std; #define in = read() typedef long long ll; const ll size = 2000 + 100; ll n; ll a[size],b[size];inline ll read(){ ll num = 0 , f = 1; char ch = getchar(); while(!isdigit(ch)){ if(ch == '-') f = -1; ch = getchar(); } while(isdigit(ch)){ num = num*10 + ch - '0'; ch = getchar(); } return num*f;}int main(){ n in; for(int i=1;i<=n;++i) a[i] in; for(int i=1;i<=n;++i) b[i] in; ll h1 = 1, h2 = 1, t1 = n, t2 = n, ans = 0; sort(a+1,a+n+1); sort(b+1,b+n+1); for(int i=1;i<=n;++i){ if(a[t1] > b[t2]){ -- t1; -- t2; ans += 200; continue; } if(a[h1] > b[h2]){ ++ h1; ++ h2; ans += 200; continue; } if(a[t1] == b[h2]){ -- t1; ++ h2; continue; } ++ h1; -- t2; ans -= 200; } printf("%d\n",ans);}//COYG

转载于:https://www.cnblogs.com/ars4me/p/7536179.html

你可能感兴趣的文章
17. Letter Combinations of a Phone Number
查看>>
高铁运营数据积累
查看>>
collections模块方法详解
查看>>
使用session防止重复提交
查看>>
10 款新鲜出炉的jQuery UI插件
查看>>
A. 【UR #16】破坏发射台
查看>>
遇到过的小问题
查看>>
梳理知识点(一)
查看>>
ftk学习记(输入框篇)
查看>>
nginx菜鸟模块开发遇到的问题汇总之nginx_array_t
查看>>
ssh登录问题
查看>>
Azure Table storage 之改进DynamicTableEntity类为其添加动态语言扩展
查看>>
在每页(分页)报表中重复显示标题 - SQL Server Reporting Service (SSRS)
查看>>
Spring的前期配置
查看>>
计算机体系结构层次-一张图诠释
查看>>
所闻所获2:使用块回调来实现代理的功能
查看>>
程序猿要知道的事情
查看>>
redis修改的源代码zincrby,hincrby命令
查看>>
积累1数
查看>>
【目标杂谈】
查看>>