2582021-03-06 16:46:30mraronÜgyeletcpp14Elfogadva 40/4014ms7560 KiB
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

using ll = long long;
using ull = unsigned long long ;
using ld = long double ;
using str = string;
using ordered_set=tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

int main() {
	IO;
	int m,n;
	cin>>m>>n;
	vector<pair<int,int>> days[100002];
	for(int i=0;i<n;++i) {
		int a,b;
		cin>>a>>b;
		days[a].push_back({b, i});
	}
	
	multiset<int> ms;
	auto second_mx=[&]() -> int {
		if(sz(ms)<=1) return 0;
		return *prev(prev(ms.end()));
	};
	
	priority_queue<pair<int,int>> pq;
	for(auto i:days[1]) pq.push(i);

	
	int covered=1;
	vector<int> ans;
	while(covered<=m && !pq.empty()) {
		auto tp=pq.top();
		pq.pop();
		ans.pb(tp.yy);
		ms.insert(tp.xx);
	
		int until=second_mx()+1;
		for(int i=covered+1;i<=until;++i) {
			for(auto j:days[i]) pq.push(j);
		}
		
		covered=until;
	}
	
	
	if(covered<=m) {
		cout<<"0\n";
		return 0;
	}
	
	cout<<sz(ans)<<"\n";
	for(auto i:ans) cout<<i+1<<" ";
	cout<<"\n";
	
	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/04ms6400 KiB
2Elfogadva0/04ms6936 KiB
3Elfogadva2/23ms6484 KiB
4Elfogadva2/23ms6484 KiB
5Elfogadva2/214ms6480 KiB
6Elfogadva2/23ms6484 KiB
7Elfogadva2/23ms6484 KiB
8Elfogadva2/24ms6520 KiB
9Elfogadva2/24ms6528 KiB
10Elfogadva2/24ms6524 KiB
11Elfogadva2/23ms6524 KiB
12Elfogadva1/14ms6536 KiB
13Elfogadva2/24ms6708 KiB
14Elfogadva2/24ms6768 KiB
15Elfogadva2/24ms6800 KiB
16Elfogadva3/37ms7560 KiB
17Elfogadva3/37ms7476 KiB
18Elfogadva3/38ms7524 KiB
19Elfogadva3/38ms7524 KiB
20Elfogadva3/38ms7520 KiB