cmd137 @ 2023-10-27 17:15:24
就输出一个数字也应该不会全WA啊
#include <iostream>
using namespace std;
int main() {
int n, times, count;
cin >> n >> times;
int arr[n + 1] = {0};
for (int i = 0; i < times; i++) {
int a = 0;
int b = 0;
cin >> a >> b;
for (int j = a; j <= b; j++) {
arr[j] = 1;
}
}
for (int i = 0; i < n + 1; i++) {
if (arr[i] == 0)
count++;
}
cout << count;
}
by Didncan_yu @ 2023-10-27 17:20:17
数组要开定值,不能写成
int arr[n + 1] = {0};
by cmd137 @ 2023-10-27 17:52:49
@Didncan_yu dev c++可以,不能写动态数组是MSVC的问题,而且按你说的应该是RE但我是WA