Codeforces 846B Math Show
来源:互联网 发布:java开发电脑配置要求 编辑:程序博客网 时间:2024/06/06 17:00
题目链接:CF-846B
最近可能会狂水一波ab题。
题意及简单分析:有n个任务,每个任务有k个子任务,每个子任务需要一些时间去完成。这n个任务可以看成完全相同的,每个任务的子任务的花费时间相同,只与它们的下标相关。每完成一个子任务获得一分,完成一个大任务(包含k个子任务)可以额外获得一分,求在M时间内,可以获得的最大分数。
表述比较混乱,可以去链接里看看原题的描述。
可以看到,数据范围太小了,直接枚举+暴力就可以。
枚举完成的大任务的数量,然后其余的子任务按时间从小排序,依次完成。
#define _CRT_SECURE_NO_WARNINGS#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <string.h>#include <algorithm>using namespace std;int main() {int n, k, M;scanf("%d %d %d", &n, &k, &M);int cost[50];int ans = 0;int sum = 0;for (int i = 0;i < k;++i)scanf("%d", &cost[i]);for (int i = 0;i < k;++i)sum += cost[i];sort(cost, cost + k);for (int i = 0;i <= n;++i) //enumberate every task to be completed{int time = M;int cur = i*sum;if (cur > time)break;else{int x = i*(k + 1);time -= cur;int left = n - i;for(int i=0;i<k;++i)for (int j = 1;j <= left;++j){if (time - cost[i] >= 0){time -= cost[i];x++;if (i == k - 1)x++;}}ans = max(ans, x);}}printf("%d\n", ans);return 0;}
阅读全文
0 0
- codeforces 846B Math Show
- Codeforces 846 B MAth Show
- Codeforces 846B Math Show
- Codeforces-846B: Math Show(dfs+贪心)
- codeforces 846/B Math Show(思维)
- Educational Codeforces Round 28 B: Math Show
- 10400 - Game Show Math
- uva10400 - Game Show Math
- UVaOJ10400 - Game Show Math
- 10400 game show math
- 10400 - Game Show Math
- 10400 -Game Show Math
- UVA10400- Game Show Math
- uva10400Game Show Math
- codeforces #483B# Friends and Presents(二分+math)
- Codeforces Problem 708B Recover the String(implementation&math)
- CodeForces - 2B -The least round way (dp math)
- Codeforces 757B Bash's Big Day math, number theory
- 【转载】你真的会用Retrofit2吗?Retrofit2完全教程
- Laravel 5.x Windows 安装过程以及遇到的坑
- gstreamer的安装与测试
- ROS kinetic+ubuntu 16.04 +rplidar A1记录
- 如何使用SpringMvc处理Rest异常
- Codeforces 846B Math Show
- 【转载】五分钟学会 Kotlin 语法
- QT之使用QReadWriteLocker互斥量同步线程小例子
- 128. Longest Consecutive Sequence
- 百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换(JS版代码)
- 查看Ubuntu的版本信息
- Arrays用法整理
- webstorm的React native代码智能提示设置
- JVM系列(一)-运行时的数据区域(总结)