HDOJ6335Nothing is Impossible(贪心)
Posted myx12345
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDOJ6335Nothing is Impossible(贪心)相关的知识,希望对你有一定的参考价值。
题意:
有n道题目m个人,每道题目有1个正确选项和a[i]个错误选项,每个人每道题只能选一个选项
求出最坏情况下分数最多的人至少能拿到几分
n<=1e2,m<=1e9,1<=b[i]<=1e2
思路:
1 #include <stdio.h> 2 #include <vector> 3 #include <algorithm> 4 #include <string.h> 5 #include <limits.h> 6 #include <string> 7 #include <iostream> 8 #include <queue> 9 #include <math.h> 10 #include <stack> 11 #include <map> 12 #define left (now<<1) 13 #define right ((now<<1)+1) 14 #define mid ((l+r)>>1) 15 using namespace std; 16 typedef long long int lint; 17 18 const int MAXN = 1e2 + 10; 19 20 lint a[MAXN],n,m; 21 22 int main(){ 23 int t; scanf("%d",&t); 24 while(t--){ 25 scanf("%d%d",&n,&m); 26 for(int i = 1; i <= n; ++i){ 27 lint b; scanf("%I64d%I64d",&b,&a[i]); 28 } 29 sort(a,a+1+n); lint k = 1; lint ans = 0; 30 for(int i = 1; i <= n; ++i){ 31 k *= 1 + a[i]; 32 if(m > k){ 33 ++ans; 34 }else{ 35 break; 36 } 37 } 38 printf("%d ",ans); 39 } 40 return 0; 41 }
以上是关于HDOJ6335Nothing is Impossible(贪心)的主要内容,如果未能解决你的问题,请参考以下文章
It is worth nothing that……是啥意思?
关于使用kms时遇到的there is nothing to do here