12564 | 2024-12-23 12:44:47 | 4rt3xp0 | 2015. november | cpp17 | Accepted | 225ms | 47428 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;
}
4
Expected output:4
Checker output:ok 1 number(s): "4"
4
Expected output:4
Checker output:ok 1 number(s): "4"
3
Expected output:3
Checker output:ok 1 number(s): "3"
5
Expected output:5
Checker output:ok 1 number(s): "5"
7
Expected output:7
Checker output:ok 1 number(s): "7"
1
Expected output:1
Checker output:ok 1 number(s): "1"
6
Expected output:6
Checker output:ok 1 number(s): "6"
2
Expected output:2
Checker output:ok 1 number(s): "2"
6
Expected output:6
Checker output:ok 1 number(s): "6"
1
Expected output:1
Checker output:ok 1 number(s): "1"
2
Expected output:2
Checker output:ok 1 number(s): "2"
7
Expected output:7
Checker output:ok 1 number(s): "7"
4
Expected output:4
Checker output:ok 1 number(s): "4"
0
Expected output:0
Checker output:ok 1 number(s): "0"
4
Expected output:4
Checker output:ok 1 number(s): "4"
5
Expected output:5
Checker output:ok 1 number(s): "5"
5
Expected output:5
Checker output:ok 1 number(s): "5"
3
Expected output:3
Checker output:ok 1 number(s): "3"
1
Expected output:1
Checker output:ok 1 number(s): "1"
8
Expected output:8
Checker output:ok 1 number(s): "8"
254
Expected output:254
Checker output:ok 1 number(s): "254"
6
Expected output:6
Checker output:ok 1 number(s): "6"
254
Expected output:254
Checker output:ok 1 number(s): "254"