102352024-03-29 17:27:09111Egyengetőcpp17Time limit exceeded 20/1003.595s4744 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;
		for(int i:v){
			if(i<x){
				c+=x-i;
			}
			if(i>x+K){
				c+=i-(x+K);
			}
		}
		return c;
	};
	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
1Accepted3ms1828 KiB
2Accepted3ms2024 KiB
subtask20/20
3Accepted4ms2228 KiB
4Accepted14ms2452 KiB
5Accepted41ms2536 KiB
6Accepted90ms2660 KiB
7Accepted293ms2760 KiB
8Time limit exceeded3.569s2748 KiB
subtask320/20
9Accepted1.296s2884 KiB
10Accepted1.312s3224 KiB
11Accepted1.314s3456 KiB
12Accepted1.297s3560 KiB
13Accepted1.297s3732 KiB
14Accepted1.302s3812 KiB
subtask40/20
15Time limit exceeded3.595s3324 KiB
16Time limit exceeded3.594s3516 KiB
17Time limit exceeded3.595s4480 KiB
18Time limit exceeded3.594s3656 KiB
19Time limit exceeded3.595s4012 KiB
20Time limit exceeded3.595s3828 KiB
subtask50/40
21Time limit exceeded3.559s4060 KiB
22Time limit exceeded3.563s4052 KiB
23Time limit exceeded3.556s4072 KiB
24Time limit exceeded3.553s4016 KiB
25Time limit exceeded3.535s4744 KiB
26Time limit exceeded3.536s4652 KiB