24872023-01-13 19:00:52kohumarkTV szolgáltatókcpp11Time limit exceeded 8/40980ms4752 KiB
#include <iostream>
#include <climits>
using namespace std;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; cin >> n >> k;
	int bj[n][2];
	int veg=0;
	for(int i=0; i<n; i++){
		cin >> bj[i][0] >> bj[i][1];
		veg=max(veg,bj[i][1]);
		bj[i][0]--; bj[i][1]--;
	}
	int petak=0; int minim=INT_MAX;
	
	
	for(int j=k-1; j<veg; j++){
		petak=0;
		for(int i=0; i<n; i++){
			if(j-k+1<bj[i][0]) petak+=bj[i][0]-(j-k+1);
			if(j>bj[i][1]) petak+=j-bj[i][1];
		}
		minim=min(minim,petak);
	}
	
	cout << minim;
}
SubtaskSumTestVerdictTimeMemory
base8/40
1Accepted0/03ms1888 KiB
2Accepted0/02ms2012 KiB
3Accepted1/13ms2220 KiB
4Accepted1/13ms2416 KiB
5Accepted1/159ms2664 KiB
6Accepted1/197ms2744 KiB
7Accepted2/297ms2996 KiB
8Accepted2/2192ms3108 KiB
9Time limit exceeded0/2971ms2432 KiB
10Time limit exceeded0/2957ms3348 KiB
11Time limit exceeded0/2972ms2888 KiB
12Time limit exceeded0/2961ms3164 KiB
13Time limit exceeded0/2972ms3056 KiB
14Time limit exceeded0/2958ms2976 KiB
15Time limit exceeded0/2953ms3552 KiB
16Time limit exceeded0/2962ms3564 KiB
17Time limit exceeded0/2970ms3236 KiB
18Time limit exceeded0/2958ms3280 KiB
19Time limit exceeded0/2970ms3256 KiB
20Time limit exceeded0/2968ms3444 KiB
21Time limit exceeded0/1976ms3728 KiB
22Time limit exceeded0/1957ms3812 KiB
23Time limit exceeded0/1977ms4224 KiB
24Time limit exceeded0/1957ms4372 KiB
25Time limit exceeded0/1962ms4492 KiB
26Time limit exceeded0/1972ms4544 KiB
27Time limit exceeded0/1980ms4552 KiB
28Time limit exceeded0/1968ms4752 KiB