模拟题,解释下题目:circle只做时间来得及的简单题(难度<a),rqy做时间来得及的困难题(难度>=b)和简单题(难度<b),其中困难题rqy需要两倍的时间来处理。
注意数据范围,然而坑的是题目没有明说每个题做题时间和难度的范围,实测不开long long会卡一组测试点,故必须开long long。遍历一遍1~n,时间复杂度为O(n),不会超时。
#include <iostream>
#include <vector>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int n,a,b;
i64 t;
std::cin >> n >> t >> a >> b;
std::vector<i64> time(n),diff(n);
for(int i = 0; i < n; i++){
std::cin >> time[i];
}
for(int i = 0; i < n; i++){
std::cin >> diff[i];
}
i64 restTime1 = t,restTime2 = t;
int ans1 = 0,ans2 = 0;
for(int i = 0; i < n; i++){
//circle
if(diff[i] < a){
if(restTime1 >= time[i]){
restTime1 -= time[i];
ans1++;
}
}
//rqy
if(diff[i] >= b){
if(restTime2 >= time[i]*2){
restTime2 -= time[i]*2;
ans2++;
}
}else{
if(restTime2 >= time[i]){
restTime2 -= time[i];
ans2++;
}
}
}
std::cout << ans1 << " " << ans2 << "\n";
}

京公网安备 11010502036488号