B. Math Show

这个题目直接暴力,还是有点难想,我没有想出来,有点思维。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <list>
#define inf 0x3f3f3f3f
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;
int a[110], vis[110];
int sum[110];
int main()
{
int n, k, m, ans = 0, sum = 0;
scanf("%d%d%d", &n, &k, &m);
for (int i = 1; i <= k; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
sort(a + 1, a + 1 + k);
for (int i = 0; i <= n; i++) {
int res = m - i * sum;
if (res < 0) break;
int num = (k + 1)*i;
for (int j = 1; j <= k; j++) {
if (res >= a[j] * (n - i)) {
res -= a[j] * (n - i);
num += n - i;
}
else {
num += res / a[j];
break;
}
}
ans = max(ans, num);
}
printf("%d\n", ans);
return 0;
}

  

C. Four Segments

这个题目我觉得还是有点难,这个题目求 res= sum[1,x-1] - sum[x,y-1] + sum[y,z-1] -sum[z, n] 的最大值

暴力枚举中间的y,然后两边贪心求x , z

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <list>
#define inf 0x3f3f3f3f
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 5e3 + 10;
ll sum[maxn], a[maxn]; int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), sum[i] = sum[i - 1] + a[i];
ll ans = 0, x = 1, y = 1, z = 1;
for(int i=1;i<=n;i++)
{
ll res1 = 0, mark1 = 1;
for (int j = i; j <= n + 1; j++) {
ll num = sum[j - 1] * 2 - sum[i - 1] - sum[n];
if (num > res1) res1 = num, mark1 = j;
}
ll res2 = 0, mark2 = 1;
for (int j = 1; j <= i; j++) {
ll num = 2 * sum[j - 1] - sum[i - 1];
if (num > res2) res2 = num, mark2 = j;
}
if(res1+res2>ans)
{
ans = res1 + res2;
x = mark2, y = i, z = mark1;
// printf("ans=%d\n", ans);
}
}
printf("%lld %lld %lld\n", x - 1, y - 1, z - 1);
return 0;
}

  

B. Math Show 暴力 C - Four Segments的更多相关文章

  1. hdu 5595 GTW likes math(暴力枚举查询)

    思路:直接暴力枚举区间[l,r]的整数值,然后max和min就可以了. AC代码: #pragma comment(linker, "/STACK:1024000000,1024000000 ...

  2. HDU 6063 17多校3 RXD and math(暴力打表题)

    Problem Description RXD is a good mathematician.One day he wants to calculate: ∑i=1nkμ2(i)×⌊nki−−−√⌋ ...

  3. 实践 HTML5 的 CSS3 Media Queries

    先来介绍下 media,确切的说应该是 CSS media queries(CSS 媒体查询),媒体查询包含了一个媒体类型和至少一个使用如宽度.高度和颜色等媒体属性来限制样式表范围的表达式.CSS3 ...

  4. 基于 CSS3 Media Queries 的 HTML5 应用

    先来介绍下 media,确切的说应该是 CSS media queries(CSS 媒体查询),媒体查询包含了一个媒体类型和至少一个使用如宽度.高度和颜色等媒体属性来限制样式表范围的表达式.CSS3 ...

  5. cesium and three.js【转】

    https://blog.csdn.net/zhishiqu/article/details/79077883 这是威尔逊Muktar关于整合Three.js与铯的客人帖子.Three.js是一个轻量 ...

  6. JS闪电打字特效

    HTML <div class="page page-thunder-to-text"> <input id="input" type=&qu ...

  7. Array and Segments (Easy version) CodeForces - 1108E1 (暴力枚举)

    The only difference between easy and hard versions is a number of elements in the array. You are giv ...

  8. HDU 6697 Closest Pair of Segments (计算几何 暴力)

    2019 杭电多校 10 1007 题目链接:HDU 6697 比赛链接:2019 Multi-University Training Contest 10 Problem Description T ...

  9. E1. Array and Segments (Easy version)(暴力) && E2. Array and Segments (Hard version)(线段树维护)

    题目链接: E1:http://codeforces.com/contest/1108/problem/E1 E2:http://codeforces.com/contest/1108/problem ...

随机推荐

  1. yum 下载全量依赖 rpm 包及离线安装(终极解决方案)

    目录 简介 验证环境 查看依赖包 方案一(推荐):repotrack 方案二:yumdownloader 方案三:yum 的 downloadonly 插件 离线安装 rpm 参考资料 简介 通常生产 ...

  2. 新时代前端必备神器 Snapjs之弹动效果

    有人说不会 SVG 的前端开发者不叫开发者,而叫爱好者.前端不光是 Angularjs 了,这时候再不学 SVG 就晚了!(如果你只会 jQuery 就当我没说...)这里我就给大家分享一个前几天在别 ...

  3. ADT_Bundle搭建

    1.打开SDK Manager.exe,打开的速度有点慢.点击右下角的[install n packages...],选择[accept ...],点击[install],然后等待安装.过程有点漫长, ...

  4. Leetcode1353-最多可以参加的会议数目

    题目描述: 给你一个数组 events,其中 events[i] = [startDayi, endDayi] ,表示会议 i 开始于startDayi ,结束于endDayi . 你可以在满足 st ...

  5. 食物链 POJ - 1182 (并查集的两种写法)

    这是一个非常经典的带权并查集,有两种写法. 1 边权并查集 规定一下,当x和y这条边的权值为0时,表示x和y是同类,当为1时,表示x吃y,当为2时,表示x被y吃. 一共有三种状态,如图,当A吃B,B吃 ...

  6. C. Standard Free2play --div

    https://codeforces.com/contest/1238/problem/C 题意:下台阶的时候只有一种方式,拉动当前台阶x的 level,然后当前的台阶关闭,调到下边的台阶x-1,如果 ...

  7. Ubuntu当状态栏网络图标隐藏的解决方法汇总

    最有效之一: 直接在终端运行以下命令,以root身份: nm-applet --sm-disable 不建议修改配置文件内容

  8. 微信小程序填坑---小程序支付

    因为公司刚刚重新做了网站,所以也吧公众号和小程序提上了日程,在公众号里面没有什么问题,直接按照官方文档进行代码编写.调试,然后就解决了公众号内支付的问题. 因为小程序提供了<webview> ...

  9. Java代码生成器加入postgresql数据库、HikariCP连接池、swagger2支持!

    目录 前言 PostgreSql VS MySql HikariCP VS Druid Swagger2 自定义参数配置一览 结语 前言   最近几天又抽时间给代码生成器增加了几个新功能(预计今晚发布 ...

  10. http_response_code()和header()

    1.http_response_code — 获取/设置响应的 HTTP 状态码向服务器发送成功状态码:http_response_code(200); 返回值如果提供了response_code,将 ...