• 【模拟】NEERC15 E Easy Problemset (2015-2016 ACM-ICPC)(Codeforces GYM 100851)


    题目链接:

      http://codeforces.com/gym/100851

    题目大意:

      N个人,每个人有pi个物品,每个物品价值为0~49。每次从1~n顺序选当前这个人的物品,如果这个物品的价值>=之前所有物品价值和则加上这个物品,否则这个物品舍弃不计算在内。

      总共拿出K个物品,如果一个人没物品拿了那么他会拿出价值为50的物品。求最终物品价值和有多少。

    题目思路:

      【模拟】

      直接暴力枚举。判断是否超过之前的总和,如果有人拿了50则后面的人肯定都是拿50。

     1 //
     2 //by coolxxx
     3 //#include<bits/stdc++.h>
     4 #include<iostream>
     5 #include<algorithm>
     6 #include<string>
     7 #include<iomanip>
     8 #include<map>
     9 #include<stack>
    10 #include<queue>
    11 #include<set>
    12 #include<bitset>
    13 #include<memory.h>
    14 #include<time.h>
    15 #include<stdio.h>
    16 #include<stdlib.h>
    17 #include<string.h>
    18 //#include<stdbool.h>
    19 #include<math.h>
    20 #define min(a,b) ((a)<(b)?(a):(b))
    21 #define max(a,b) ((a)>(b)?(a):(b))
    22 #define abs(a) ((a)>0?(a):(-(a)))
    23 #define lowbit(a) (a&(-a))
    24 #define sqr(a) ((a)*(a))
    25 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
    26 #define mem(a,b) memset(a,b,sizeof(a))
    27 #define eps (1e-8)
    28 #define J 10
    29 #define mod 1000000007
    30 #define MAX 0x7f7f7f7f
    31 #define PI 3.14159265358979323
    32 #define N 104
    33 using namespace std;
    34 typedef long long LL;
    35 int cas,cass;
    36 int n,m,lll,ans;
    37 int a[N][N];
    38 int sum,total;
    39 int main()
    40 {
    41 //    freopen("easy.in","r",stdin);
    42 //    freopen("easy.out","w",stdout);
    43     int i,j,k;
    44     
    45 //    for(scanf("%d",&cass);cass;cass--)
    46 //    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
    47 //    while(~scanf("%s",s+1))
    48     while(~scanf("%d",&n))
    49     {
    50         mem(a,0);sum=0,total=0;
    51         scanf("%d",&m);
    52         for(i=1;i<=n;i++)
    53         {
    54             scanf("%d",&a[i][0]);
    55             for(j=1;j<=a[i][0];j++)
    56             {
    57                 scanf("%d",&a[i][j]);
    58             }
    59         }
    60         for(j=1;j<=10 && total!=m;j++)
    61         {
    62             for(i=1;i<=n && total!=m;i++)
    63             {
    64                 if(j>a[i][0])
    65                 {
    66                     sum+=50;
    67                     total++;
    68                     continue;
    69                 }
    70                 if(a[i][j]>=sum)
    71                 {
    72                     sum+=a[i][j];
    73                     total++;
    74                 }
    75             }
    76         }
    77         if(total<m)
    78             sum+=50*(m-total);
    79         printf("%d
    ",sum);
    80     }
    81     return 0;
    82 }
    83 /*
    84 //
    85 
    86 //
    87 */
    View Code
  • 相关阅读:
    C#中IPAddress转换成整型int
    没有注册类 (异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG))
    VB.NET或C#报错:You must hava a license to use this ActiveX control.
    c#几种随机数组和数组乱序
    C#封装的websocket协议类
    VB生成条形码(EAN-13)
    VB控件间的拖放
    VB用API模拟截屏键PrintScreen
    VB读写进程的内存
    几个VB常见又内涵的错误
  • 原文地址:https://www.cnblogs.com/Coolxxx/p/5822432.html
Copyright © 2020-2023  润新知