29282023-02-04 15:20:32horvathabelBenzinkút üzemeltetés (55)cpp17Wrong answer 15/554ms4136 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({y,x,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
base15/55
1Accepted0/03ms1808 KiB
2Wrong answer0/04ms2212 KiB
3Accepted3/33ms2232 KiB
4Accepted3/33ms2352 KiB
5Accepted3/33ms2604 KiB
6Accepted3/33ms2696 KiB
7Accepted3/32ms2820 KiB
8Wrong answer0/32ms2776 KiB
9Wrong answer0/33ms3040 KiB
10Wrong answer0/33ms3144 KiB
11Wrong answer0/33ms3520 KiB
12Wrong answer0/33ms3636 KiB
13Wrong answer0/43ms3828 KiB
14Wrong answer0/43ms4036 KiB
15Wrong answer0/54ms4004 KiB
16Wrong answer0/64ms4136 KiB
17Wrong answer0/64ms3972 KiB