Archived
22:58(45pts)
This commit is contained in:
1 parent
d09bb7de83
commit
bf08016dee
2 files changed
+24
-4
No files matched your search
+24
-4
@@ -2,15 +2,35 @@
|
||||
using namespace std;
|
||||
int n;
|
||||
long long m;
|
||||
int a[500005];
|
||||
long long a[500005];
|
||||
long long check(long long now) {
|
||||
int tot = lower_bound(a + 1, a + n + 1, now) - a - 1;
|
||||
// printf("%d\n", tot);
|
||||
long long nowm = m;
|
||||
long long ans = 0;
|
||||
while(a[tot + 1] == now && tot + 1 <= n) tot++;
|
||||
while(nowm >= (now - a[tot]) && tot >= 1) {
|
||||
nowm -= now - a[tot], ans++, tot--;
|
||||
// printf("%lld %d\n", nowm, tot);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
int main() {
|
||||
freopen("crystal.in", "r", stdin);
|
||||
freopen("crystal.out", "w", stdout);
|
||||
// freopen("crystal.out", "w", stdout);
|
||||
scanf("%d%lld", &n, &m);
|
||||
for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
|
||||
|
||||
for(int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
|
||||
sort(a + 1, a + n + 1);
|
||||
long long ans = 0;
|
||||
for(int i = 1; i <= n; ++i) {
|
||||
ans = max(ans, check(a[i]));
|
||||
}
|
||||
printf("%lld\n", ans);
|
||||
// printf("%lld\n", check(4));
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
g++ crystal/crystal.cpp -o crystal/crystal -std=c++14 -O2 -static -Wall && cp crystal/crystal ~ && chmod +x ~/crystal && ~/crystal
|
||||
O(n log n)
|
||||
45pts
|
||||
*/
|
||||
Whitespace-only changes.
Reference in new issue
Block a user