Problem A. Mischievous Problem Setter

 签到.

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 #define ll long long
 5 #define N 100010
 6 #define pii pair <int, int>
 7 #define x first
 8 #define y second
 9 int t, n, m;
10 pii a[N];
11 
12 int main()
13 {
14     scanf("%d", &t);
15     for (int kase = 1; kase <= t; ++kase)
16     {
17         printf("Case %d: ", kase);
18         scanf("%d%d", &n, &m);
19         for (int i = 1; i <= n; ++i) scanf("%d", &a[i].x);
20         for (int i = 1; i <= n; ++i) scanf("%d", &a[i].y);
21         sort(a + 1, a + 1 + n);
22         int res = 0;
23         for (int i = 1; i <= n; ++i) 
24         {
25             if (a[i].y <= m)
26             {
27                 ++res;
28                 m -= a[i].y;
29             }
30             else 
31                 break;
32         }
33         printf("%d\n", res);
34     }
35     return 0;
36 }
View Code

相关文章:

  • 2021-10-18
  • 2021-06-14
  • 2022-02-17
  • 2021-12-07
  • 2021-11-24
  • 2021-05-22
猜你喜欢
  • 2021-11-15
  • 2021-11-13
  • 2021-07-15
  • 2021-09-10
  • 2021-11-20
  • 2022-12-23
相关资源
相似解决方案