-
个人简介
#include<bits/stdc++.h> using namespace std; pair<int, int> a[147292]; pair<int, int> b[147292]; int n, m, T; int calc(int u, int v) { if (u >= T || v >= T) { return calc(u / 10, v / 10); } else { int res = 0; if (u % T == v % T) { res = 0; } else if (u % T > v % T) { res = 1; } else { res = -1; } return res; } } bool cmp(const pair<int, int>& u, const pair<int, int>& v) { int res = max(0, calc(u.first, v.first)); return res!= 0? res > 0 : false; } int main() { int mx = 0; cin >> n >> m; T = abs(n - m) + 2; for (int i = 1; i <= n; i++) { cin >> a[i].first >> a[i].second; if (calc(mx, a[i].first) < 0) { mx = a[i].first; } } for (int i = 1; i <= n; i++) { b[i] = make_pair(a[i].second, a[i].first); } sort(b + 1, b + n + 1, cmp); int ans = 0; for (int i = 1; i <= n && calc(b[i].first, mx) > 0 && m > 0; i++, ans++) { m -= b[i].first; } cout << ans + (m + mx - 1) / mx; return 0; }
#include<bits/stdc++.h> using namespace std;
pair<int, int> a[147292]; pair<int, int> b[147292]; int n, m, T;
int calc(int u, int v) { if (u >= T || v >= T) { return calc(u / 10, v / 10); } else { int res = 0; if (u % T == v % T) { res = 0; } else if (u % T > v % T) { res = 1; } else { res = -1; } return res; } }
bool cmp(const pair<int, int>& u, const pair<int, int>& v) { int res = max(0, calc(u.first, v.first)); return res!= 0? res > 0 : false; }
int main() { int mx = 0; cin >> n >> m; T = abs(n - m) + 2; for (int i = 1; i <= n; i++) { cin >> a[i].first >> a[i].second; if (calc(mx, a[i].first) < 0) { mx = a[i].first; } } for (int i = 1; i <= n; i++) { b[i] = make_pair(a[i].second, a[i].first); } sort(b + 1, b + n + 1, cmp); int ans = 0; for (int i = 1; i <= n && calc(b[i].first, mx) > 0 && m > 0; i++, ans++) { m -= b[i].first; } cout << ans + (m + mx - 1) / mx; return 0; }
-
通过的题目
-
最近活动
This person is lazy and didn't join any contests or homework. -
最近编写的题解
This person is lazy and didn't write any solutions.