1 solutions

  • 0
    @ 2024-8-29 22:08:23

    👍

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
    	int l, m, f[10010], ans = 0;
    	cin >> l >> m;
    	for (int i = 0; i <= l; i++) {
    		f[i] = 1;
    	}
    	for (int i = 1; i <= m; i++) {
    		int u, v;
    		cin >> u >> v;
    		for (int k = u; k <= v; k++) {
    			f[k] = 0;
    		}
    	}
    	for (int i = 0; i <= l; i++) {
    		if (f[i] == 1) {
    			ans++;
    		}
    	}
    	cout << ans;
    	return 0;
    }
    
    • 1

    【深基5.例4】[NOIP2005 普及组] 校门外的树

    Information

    ID
    80
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By