QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#519630#2544. Flatland CurrencyNevllWA 0ms4096kbC++14771b2024-08-14 22:23:282024-08-14 22:23:29

Judging History

This is the latest submission verdict.

  • [2024-08-14 22:23:29]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 4096kb
  • [2024-08-14 22:23:28]
  • Submitted

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'