11 条题解
-
1
#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; }
-
1
#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
#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
#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
#include<iomanip> #include<cmath> #include<cstring> using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; int l,m,x,y,ans; bool a[N]; int main() { cin>>l>>m; while(m--) { cin>>x>>y; for(int i=x;i<=y;i++) a[i]=1; } for(int i=0;i<=l;i++) { if(!a[i]) ans++; } cout<<ans; return 0; }
-
0
#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
#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:;) # 信息 递交者 [尹晨恩 (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
#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
#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
#include<bits/stdc++.h>
#include
#include <math.h>
#include
#include <stdio.h>
#include
#include
#include
#include <string.h>
#include
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
- 难度
- 6
- 标签
- 递交数
- 919
- 已通过
- 259
- 上传者