102422024-03-29 17:54:05111Egyengetőcpp17Runtime error 0/1002.003s4576 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;
	if(N>1000)return 1;
	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)<=v.size()-c1-c2?c:1e18;
	};
	for(int i=0;i<N;i++){
		int y=Data();
		v.push_back(y);
		v.push_back(y-K);
		sort(v.begin(),v.end());
		int ans=1e18;
		for(int j:v){
			ans=min(ans,calc(j));
		}
		Solution(ans/2);
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2052 KiB
subtask20/20
3Accepted6ms2236 KiB
4Accepted21ms2456 KiB
5Accepted61ms2804 KiB
6Accepted145ms3008 KiB
7Accepted451ms3108 KiB
8Runtime error3ms3204 KiB
subtask30/20
9Wrong answer3ms3296 KiB
10Wrong answer3ms3376 KiB
11Accepted2.003s3508 KiB
12Accepted1.975s3408 KiB
13Wrong answer3ms3380 KiB
14Wrong answer3ms3504 KiB
subtask40/20
15Runtime error3ms3712 KiB
16Runtime error3ms3948 KiB
17Runtime error3ms4144 KiB
18Runtime error3ms4240 KiB
19Runtime error3ms4364 KiB
20Runtime error2ms4364 KiB
subtask50/40
21Runtime error3ms4336 KiB
22Runtime error3ms4344 KiB
23Runtime error3ms4440 KiB
24Runtime error3ms4572 KiB
25Runtime error3ms4576 KiB
26Runtime error3ms4556 KiB