QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#519630 | #2544. Flatland Currency | Nevll | WA | 0ms | 4096kb | C++14 | 771b | 2024-08-14 22:23:28 | 2024-08-14 22:23:29 |
Judging History
answer
# include <bits/stdc++.h>
# define ll long long
# define ld long double
# define pii pair<int, int>
# define fi first
# define se second
using namespace std;
int main() {
int N;
ll X;
scanf("%d %lld", &N, &X);
vector<ll> arr(N), B(N);
for(int i=0;i<N;i++) {
scanf("%lld", &arr[i]);
}
sort(arr.begin(), arr.end());
for(int i=0;i<N;i++) {
B[i] = 5 - (arr[i]%5);
if(B[i] == 5) B[i] = 0ll;
arr[i] += B[i];
}
ll ans = X%5;
X -= X%5;
int lf = -1;
ll sum = 0ll, as = 0ll, mx = 0ll;
for(int i=0;i<N;i++) {
while(lf + 1 < N && sum + arr[lf + 1] <= X) {
lf++;
sum += arr[lf];
as += B[lf];
mx = max(mx, as);
}
sum -= arr[i];
as -= B[i];
}
ans += mx;
printf("%lld\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4096kb
input:
5 57 9 14 31 18 27
output:
7
result:
wrong answer expected '8', found '7'