社区讨论
挑战竞争最唐赛时代码
P14635[NOIP2025] 糖果店参与者 2已保存回复 4
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @mir0w00h
- 此快照首次捕获于
- 2025/12/04 13:56 3 个月前
- 此快照最后确认于
- 2025/12/06 14:10 2 个月前
100 -> 45pts
DIFF#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
typedef long long ll;
typedef pair<int, int> pi;
#define endl '\n'
#define ff(i, j, k) for(int i = j; i <= k; i ++)
int n;
- int m;
+ ll m;
pi a[N];
int dp[10010];
pi from[1010][10010];
struct node {
double v;
int type, id;
bool operator < (const node& x) const {
if (v == x.v) return type < x.type;
return v < x.v;
}
}b[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
clock_t ___c = clock();
cin >> n >> m;
priority_queue<node> q;
int mi = 2e9;
ff(i, 1, n) {
cin >> a[i].first >> a[i].second;
mi = min(mi, a[i].first + a[i].second);
}
sort (a + 1, a + 1 + n);
ll sum = 0, ans = 0;
- ff (i, 1, n) {
+ ff (i, 0, n) {
sum += a[i].first;
+ if (sum > m) break;
ans = max(ans, i + (m - sum) / mi * 2);
}
cout << ans << endl;
cerr << "----------------\nRUNTIME " << clock() - ___c << " MS" << endl;
return 0;
}
回复
共 4 条回复,欢迎继续交流。
正在加载回复...