社区讨论
NOIP T1正确性求证明
学术版参与者 3已保存回复 4
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @mik3slb3
- 此快照首次捕获于
- 2025/11/29 17:43 3 个月前
- 此快照最后确认于
- 2025/11/30 16:40 3 个月前
rt,考场上写的:
CPP#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 1;
ll m;
int n;
struct node
{
ll x, y;
}a[N];
bool cmp(node x, node y)
{
return x.x + x.y < y.x + y.y;
}
bool cmp2(node x, node y)
{
return x.x < y.x;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("candy.in", "r", stdin);
// freopen("candy.out", "w", stdout);
cin >> n >> m;
for(int i = 1; i <= n; i++)
{
cin >> a[i].x >> a[i].y;
}
sort(a + 1, a + n + 1, cmp);
sort(a + 2, a + n + 1, cmp2);
ll cnt = a[1].x + a[1].y, ans = m / cnt * 2 + (m % cnt >= a[1].x);
ll sum = 0;
for(int i = 2; i <= n; i++)
{
sum += a[i].x;
if(sum > m) break;
ans = max(ans, i - 1 + (m - sum) / cnt * 2 + ((m - sum) % cnt >= a[1].x));
}
cout << ans;
return 0;
}
回复
共 4 条回复,欢迎继续交流。
正在加载回复...