10 条题解

  • 1
    @ 2023-4-9 19:39:12

    #include <bits/stdc++.h> using namespace std;

    int main() { int a [10010]; int l, n; cin >> l >> n;

    for (int i = 0; i <= l; i++)
        a[i] = 1;
    
    while (n--) {
        int s, e;
        cin >> s >> e;
    
        for (int i = s; i <= e; i++)
            a[i] = 0;
    }
    
    int ans = 0;
    
    for (int i = 0; i <= l; i++)
        ans += a[i];
    
    cout << ans << endl;
    return 0;
    

    }

    • 1
      @ 2023-4-9 17:53:18

      #include <bits/stdc++.h> using namespace std;

      int main() { int a [10010]; int l, n; cin >> l >> n;

      for (int i = 0; i <= l; i++)
          a[i] = 1;
      
      while (n--) {
          int s, e;
          cin >> s >> e;
      
          for (int i = s; i <= e; i++)
              a[i] = 0;
      }
      
      int ans = 0;
      
      for (int i = 0; i <= l; i++)
          ans += a[i];
      
      cout << ans << endl;
      return 0;
      

      }

      • 1
        @ 2023-3-7 17:24:28

        #include <bits/stdc++.h> using namespace std;

        int main() { int a [10010]; int l, n; cin >> l >> n;

        for (int i = 0; i <= l; i++)
            a[i] = 1;
        
        while (n--) {
            int s, e;
            cin >> s >> e;
        
            for (int i = s; i <= e; i++)
                a[i] = 0;
        }
        
        int ans = 0;
        
        for (int i = 0; i <= l; i++)
            ans += a[i];
        
        cout << ans << endl;
        return 0;
        

        }

        • 0
          @ 2024-9-28 12:51:19

          #include <bits/stdc++.h> using namespace std;

          int main() { int a [10010]; int l, n; cin >> l >> n;

          for (int i = 0; i <= l; i++)
              a[i] = 1;
          
          while (n--) {
              int s, e;
              cin >> s >> e;
          
              for (int i = s; i <= e; i++)
                  a[i] = 0;
          }
          
          int ans = 0;
          
          for (int i = 0; i <= l; i++)
              ans += a[i];
          
          cout << ans << endl;
          return 0;
          

          }

          • 0
            @ 2024-7-31 9:14:22
            #include<bits/stdc++.h>
            using namespace std;
            const int N = 1e5 + 10;
            int a[N];
            int main()
            {
            	int n,m;
            	cin>>n>>m;
            	for(int i = 0,l,r ; i < m ;i++)
            	{
            		cin >> l >> r;
            		for(int j = l ; j <= r ; j++)
            		{
            			a[j] = 1;
            		}
            	}
            	int ans = 0;
            	for(int i = 0 ; i <= n ; i++ )
            	{
            		if(a[i] == 0)
            			ans++;
            	}
            	cout << ans << endl;
            	return 0;
            }
            
            
            • 0
              @ 2024-5-26 9:14:33
              #include<bits/stdc++.h>
              using namespace std;
              int main(){
              	int L,sum=0;
              	cin>>L;
              	int a[10001]={};
              	int M;
              	cin>>M;
              	int x,y;
              	for(int i=0;i<M;i++){
              		cin>>x>>y;
              		for(int j=x;j<=y;j++){
              			a[j]=1;
              		}
              	}
              	for(int i=0;i<=L;i++){
              		if(a[i]==0){
              			sum++;
              		}
              	}
              	cout<<sum;
              	return 0;
              }
              ```
              
              [Copy](javascript:;)
              
              
              
              
              
              
              # 信息
              
              
              递交者![](http://cn.gravatar.com/avatar/190c4015cc8e9d4a9ea1ae5d1f5423b2?d=mm&s=64) [尹晨恩 (yinchenen) ](http://temege.com/user/3744)[LV 4](http://temege.com/user/3744)题目[**P677**  校门外的树](http://temege.com/p/677)语言C++ 11递交时间**4 分钟前**分数100总耗时7ms峰值内存312 KiB
              
              
              
              
              
              # 状态
              
              * [评测队列](http://temege.com/record)
              * [服务状态](http://temege.com/status)
              
              
              
              # 开发
              
              * [开源](https://github.com/hydro-dev/Hydro)
              
              ```
              
              • 0
                @ 2023-7-10 11:13:13
                #include<stdio.h>
                #include<iostream>
                using namespace std; 
                const int N=1e4+10;
                const int INF=0x3f3f3f3f; 
                int L,M,sum;        
                bool a[N];
                
                int main()
                {
                    cin>>L>>M;
                    for(int i=1;i<=M;i++)
                    {
                    	int x,y;
                    	cin>>x>>y;
                		for(int j=x;j<=y;j++)
                			a[j]=1;
                	}
                    
                	for(int i=0;i<=L;i++)
                    	if(a[i]==0)
                        	sum++;
                        
                    cout<<sum;
                    return 0;
                }
                
                • 0
                  @ 2022-7-9 20:49:36

                  #include <stdio.h> #include <iostream> using namespace std; int a[1000000]; int main() { int n , t ; cin >> n >> t ; while(t--) { int l , r ; cin >> l >> r ; for(int i = l ; i <= r ; i++) a[i] = 1;

                  }
                  int sum = 0;
                  for(int i =0 ; i <= n ; i++)
                      if(a[i] == 0)
                          sum++;
                  cout << sum << endl;
                  

                  }

                  • 0
                    @ 2021-10-6 19:51:18
                    #include <bits/stdc++.h>
                    using namespace std;
                    
                    int main() {
                        int a [10010];
                        int l, n;
                        cin >> l >> n;
                    
                        for (int i = 0; i <= l; i++)
                            a[i] = 1;
                    
                        while (n--) {
                            int s, e;
                            cin >> s >> e;
                    
                            for (int i = s; i <= e; i++)
                                a[i] = 0;
                        }
                    
                        int ans = 0;
                    
                        for (int i = 0; i <= l; i++)
                            ans += a[i];
                    
                        cout << ans << endl;
                        return 0;
                    }
                    
                    
                    • -1
                      @ 2022-7-12 11:38:42

                      #include<bits/stdc++.h>

                      #include <queue>

                      #include <math.h>

                      #include <stack>

                      #include <stdio.h>

                      #include <iostream>

                      #include <vector>

                      #include <iomanip>

                      #include <string.h>

                      #include <algorithm>

                      using namespace std;

                      #define LL long long

                      const int N = 1e5 + 10;

                      const int INF = 0x3f3f3f3f;

                      using namespace std;

                      int main()

                      {

                      int a [10010];
                      
                      int l, n;
                      
                      cin >> l >> n;
                      
                      for (int i = 0; i <= l; i++)
                      
                          a[i] = 1;
                      
                      while (n--) {
                      
                          int s, e;
                      
                          cin >> s >> e;
                      
                          for (int i = s; i <= e; i++)
                      
                              a[i] = 0;
                      
                      }
                      
                      int ans = 0;
                      
                      for (int i = 0; i <= l; i++)
                      
                          ans += a[i];
                      
                      cout << ans << endl;
                      
                      return 0;
                      

                      }

                      • 1

                      信息

                      ID
                      677
                      时间
                      1000ms
                      内存
                      256MiB
                      难度
                      7
                      标签
                      递交数
                      830
                      已通过
                      210
                      上传者