24902023-01-13 19:16:15kohumarkTV szolgáltatókcpp11Time limit exceeded 8/40981ms6152 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];
		}
		if(minim<petak) break;
		minim=min(minim,petak);
	}
	
	cout << minim;
}
SubtaskSumTestVerdictTimeMemory
base8/40
1Accepted0/03ms1760 KiB
2Accepted0/02ms1996 KiB
3Accepted1/12ms2128 KiB
4Accepted1/13ms2608 KiB
5Accepted1/130ms2620 KiB
6Accepted1/152ms2772 KiB
7Accepted2/248ms2972 KiB
8Accepted2/297ms3196 KiB
9Time limit exceeded0/2962ms3404 KiB
10Time limit exceeded0/2961ms3628 KiB
11Time limit exceeded0/2970ms3312 KiB
12Time limit exceeded0/2966ms3308 KiB
13Time limit exceeded0/2968ms3524 KiB
14Time limit exceeded0/2973ms3500 KiB
15Time limit exceeded0/2961ms4188 KiB
16Time limit exceeded0/2970ms4224 KiB
17Time limit exceeded0/2973ms3884 KiB
18Time limit exceeded0/2968ms4140 KiB
19Time limit exceeded0/2953ms4164 KiB
20Time limit exceeded0/2958ms4136 KiB
21Wrong answer0/1287ms5484 KiB
22Time limit exceeded0/1962ms4220 KiB
23Wrong answer0/1584ms6152 KiB
24Time limit exceeded0/1944ms4516 KiB
25Time limit exceeded0/1972ms4596 KiB
26Time limit exceeded0/1958ms4776 KiB
27Time limit exceeded0/1981ms4796 KiB
28Time limit exceeded0/1944ms4912 KiB