102402024-03-29 17:39:24111Egyengetőcpp17Wrong answer 0/1003.595s3572 KiB
#include <bits/stdc++.h>
using namespace std;

#include "grader.h"

#define int long long

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N=getN(),K=getK(),M=4e8;
	vector<int>v;
	auto calc=[&](int x)->int{
		int c=0,c1=0,c2=0;
		for(int i:v){
			if(i<x){
				c1++;
				c+=x-i;
			}
			if(i>x+K){
				c2++;
				c+=i-(x+K);
			}
		}
		return abs(c2-c1)<=1?c:1e18;
	};
	for(int i=0;i<N;i++){
		v.push_back(Data());
		sort(v.begin(),v.end());
		int ans=1e18;
		for(int j=0;j<=i;j++){
			ans=min(ans,calc(v[j]));
			ans=min(ans,calc(v[j]-K));
		}
		Solution(ans);
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1824 KiB
2Accepted3ms2024 KiB
subtask20/20
3Accepted4ms2240 KiB
4Accepted16ms2344 KiB
5Accepted43ms2420 KiB
6Wrong answer8ms2552 KiB
7Wrong answer4ms2632 KiB
8Time limit exceeded3.571s2152 KiB
subtask30/20
9Accepted1.343s2856 KiB
10Accepted1.348s2984 KiB
11Accepted1.338s3068 KiB
12Accepted1.314s3196 KiB
13Accepted1.315s3280 KiB
14Wrong answer115ms3440 KiB
subtask40/20
15Wrong answer3ms3476 KiB
16Time limit exceeded3.595s2844 KiB
17Time limit exceeded3.592s2976 KiB
18Time limit exceeded3.594s3572 KiB
19Time limit exceeded3.592s2856 KiB
20Time limit exceeded3.595s2828 KiB
subtask50/40
21Time limit exceeded3.558s3476 KiB
22Wrong answer100ms3484 KiB
23Wrong answer4ms3480 KiB
24Time limit exceeded3.552s3480 KiB
25Time limit exceeded3.532s2940 KiB
26Time limit exceeded3.535s3500 KiB