Codeforces 846 B MAth Show
来源:互联网 发布:js cookie 永不过期 编辑:程序博客网 时间:2024/06/08 00:55
题目地址
题意:你要运行n次大程序,每个大程序里面有m个小程序,运行程序不用管顺序,可以随意运行,只要每个小程序运行不超过n次就好了。每运行完一个小程序你可以加1分,运行完一个大程序可以附加1分。问在t的时间内,最大的分数是多少?
思路:因为数据范围比较小,所以直接暴力就好了,O(n^2)的算法。先给每个小程序的耗时排序,每次枚举完整运行多少个大程序,先把这些算完,然后剩下的就让最短时间的小程序排序去跑。最后算最大值就好了。
#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <algorithm>#include <iomanip>#define N 50#define M 555005 #define LL __int64#define inf 0x3f3f3f3f#define lson l,mid,ans<<1#define rson mid+1,r,ans<<1|1#define getMid (l+r)>>1#define movel ans<<1#define mover ans<<1|1using namespace std;const LL mod = 1000000007;int num[N];int main() { cin.sync_with_stdio(false); int n, m, t; int sum, mmax; while (cin >> n >> m >> t) { sum = 0; for (int i = 0; i < m; i++) { cin >> num[i]; sum += num[i]; } mmax = 0; sort(num, num + m); for (int i = 0; i <= n; i++) { int ans = t - i*sum; if (ans < 0) { break; } int cnt = m*i + i; for (int j = 0; j < m; j++) { if (ans >= num[j] * (n - i)) { cnt += (n - i); ans -= (n - i)*num[j]; } else { cnt += (ans / num[j]); break; } } mmax = max(mmax, cnt); } cout << mmax << endl; } 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
- python: time模块、datetime模块
- 进程的基本状态
- 十进制与二进制相互转换(包括带小数点)
- python基础——面向对象
- 代码整洁_迭进
- Codeforces 846 B MAth Show
- 移植程序步骤及注意点(keil5)
- Python学习笔记day05
- Numpy学习笔记——矩阵和通用函数
- 基于SRAM的内存管理
- 进程和线程定义,概念,区别详解
- ASP.NET MVC上传文件
- aardio学习记录-1.基本概念和自定义类的调用
- 突发事件属性库构建