好不甘心,C++,通过85%,感觉思路比较清楚,有无大佬给点修改意见int num; cin>>num;int a, b; vector<vector<int>> vec;int x = 1000000; int y = -1;while (cin >> a >> b){//确定运行时间的左右区间if (x > a) x = a;if (y < b) y = b;vector<int>tmp:tmp.push_back(a);tmp.push_back(b);vec.push_back(tmp);} vector<int> time(b + 1, 0);//时间序列数组for (int i = 0 : i < vec.size(); i++)for (int j = vec[i][0] ; j <= vec[i][1]; j++)time[i]++;//对于每个时间片计算该时间片运行程序的个数int ans = 0;for (int i = 0; i < time.size(); i++){if (time[i] == 0 & time[i] >= x)//空载但要开始运行过后才消耗资源ans += 1;if (time[i] == 1)ans += 3;if (time[i] > 1)ans += 4;}cout <<ans;return 0