125642024-12-23 12:44:474rt3xp02015. novembercpp17Accepted 225ms47428 KiB
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,p; cin >> n >> p;
  multiset<int> v[n];
  for(int i=0;i<n;i++){
    int a,h; cin >> a >> h;
    for(int j=0;j<n;j++){
      if(j==i) v[j].insert(a/2+h);
      else v[j].insert(a+h);
    }
  }
  int mx=0;
  for(int i=0;i<n;i++){
    int s=p,cnt=0;
    for(int x: v[i]){
      s-=x;
      if(s>=0) cnt++;
      else break;
    }
    mx=max(mx,cnt);
  }
  cout << mx;
}
1 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
4
Expected output:
4
Checker output:
ok 1 number(s): "4"

2 - Accepted
Memory: 1080KiB
Time: 3ms

Program's output:
4
Expected output:
4
Checker output:
ok 1 number(s): "4"

3 - Accepted
Memory: 568KiB
Time: 1ms

Program's output:
3
Expected output:
3
Checker output:
ok 1 number(s): "3"

4 - Accepted
Memory: 18136KiB
Time: 61ms

Program's output:
5
Expected output:
5
Checker output:
ok 1 number(s): "5"

5 - Accepted
Memory: 25144KiB
Time: 87ms

Program's output:
7
Expected output:
7
Checker output:
ok 1 number(s): "7"

6 - Accepted
Memory: 36156KiB
Time: 130ms

Program's output:
1
Expected output:
1
Checker output:
ok 1 number(s): "1"

7 - Accepted
Memory: 9272KiB
Time: 32ms

Program's output:
6
Expected output:
6
Checker output:
ok 1 number(s): "6"

8 - Accepted
Memory: 26936KiB
Time: 108ms

Program's output:
2
Expected output:
2
Checker output:
ok 1 number(s): "2"

9 - Accepted
Memory: 34360KiB
Time: 150ms

Program's output:
6
Expected output:
6
Checker output:
ok 1 number(s): "6"

10 - Accepted
Memory: 29496KiB
Time: 122ms

Program's output:
1
Expected output:
1
Checker output:
ok 1 number(s): "1"

11 - Accepted
Memory: 1592KiB
Time: 4ms

Program's output:
2
Expected output:
2
Checker output:
ok 1 number(s): "2"

12 - Accepted
Memory: 12844KiB
Time: 41ms

Program's output:
7
Expected output:
7
Checker output:
ok 1 number(s): "7"

13 - Accepted
Memory: 824KiB
Time: 3ms

Program's output:
4
Expected output:
4
Checker output:
ok 1 number(s): "4"

14 - Accepted
Memory: 37820KiB
Time: 165ms

Program's output:
0
Expected output:
0
Checker output:
ok 1 number(s): "0"

15 - Accepted
Memory: 16184KiB
Time: 61ms

Program's output:
4
Expected output:
4
Checker output:
ok 1 number(s): "4"

16 - Accepted
Memory: 27704KiB
Time: 112ms

Program's output:
5
Expected output:
5
Checker output:
ok 1 number(s): "5"

17 - Accepted
Memory: 38200KiB
Time: 162ms

Program's output:
5
Expected output:
5
Checker output:
ok 1 number(s): "5"

18 - Accepted
Memory: 1340KiB
Time: 4ms

Program's output:
3
Expected output:
3
Checker output:
ok 1 number(s): "3"

19 - Accepted
Memory: 568KiB
Time: 1ms

Program's output:
1
Expected output:
1
Checker output:
ok 1 number(s): "1"

20 - Accepted
Memory: 44060KiB
Time: 189ms

Program's output:
8
Expected output:
8
Checker output:
ok 1 number(s): "8"

21 - Accepted
Memory: 47416KiB
Time: 224ms

Program's output:
254
Expected output:
254
Checker output:
ok 1 number(s): "254"

22 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
6
Expected output:
6
Checker output:
ok 1 number(s): "6"

23 - Accepted
Memory: 47428KiB
Time: 225ms

Program's output:
254
Expected output:
254
Checker output:
ok 1 number(s): "254"