90!!!
查看原帖
90!!!
1058749
King_and_Grey楼主2024/5/28 17:11
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k,ans;
bool isok[100000];
struct node{
	int begin,end;
}a[105];

signed main(){
	cin >> n >> k;
	memset(isok,true,sizeof(isok));
	for (int i = 1; i <= k; i++){
		cin >> a[i].begin >> a[i].end;
	}
	for(int i = 1; i <= k; i++){
		for(int j = a[i].begin; j <= a[i].end ;j++){
			if(isok[j] == true){
				isok[j] = false;
			}
		}
	}
	for(int i = 1; i <= n ;i++){
		if(isok[i] == true){
			ans++;
		}
	}
	cout << ans + 1 << endl;
	return 0;
}

我不懂!!! 明明我考虑了左端点从一开始的情况

2024/5/28 17:11
加载中...