29402023-02-04 17:46:14horvathabelBenzinkút üzemeltetés (55)cpp17Wrong answer 4/553ms4968 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,k;
	cin>>n>>k;
	vector<vector<int>> q; 
	for(int i=0; i<n;i++){
		int x,y; 
		cin>>x>>y; 
		q.push_back({x,y,i+1});
	}
	int ans=0;
	vector<int> mego;
	sort(q.begin(), q.end(), greater<vector<int>>());
	vector<int> foglalt;
	for (auto x:q){
		bool szabad=true; 
		for (int z:foglalt){
			if (x[1]<z+k && x[1]>z-k){
				 szabad=false; 
				break;
			}
		}	
		if (szabad){
			ans+=x[0];
			foglalt.push_back(x[1]); 
			mego.push_back(x[2]);
		}
	}
	cout<<ans<<endl<<foglalt.size()<<" ";
	sort(mego.begin(), mego.end());
	for (auto x: mego) cout<<x<<" "; 
}
SubtaskSumTestVerdictTimeMemory
base4/55
1Wrong answer0/03ms1812 KiB
2Wrong answer0/03ms2236 KiB
3Partially correct1/33ms2232 KiB
4Wrong answer0/33ms2464 KiB
5Wrong answer0/33ms2680 KiB
6Accepted3/33ms2864 KiB
7Wrong answer0/33ms3076 KiB
8Wrong answer0/33ms3320 KiB
9Wrong answer0/33ms3536 KiB
10Wrong answer0/33ms3624 KiB
11Wrong answer0/33ms3640 KiB
12Wrong answer0/33ms3788 KiB
13Wrong answer0/43ms4108 KiB
14Wrong answer0/43ms4316 KiB
15Wrong answer0/53ms4536 KiB
16Wrong answer0/63ms4868 KiB
17Wrong answer0/63ms4968 KiB