题目描述
blablabla
样例
blablabla
算法1
(优先队列版)
blablabla
时间复杂度
参考文献
C++ 代码
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int N = 110;
int s[N], d[N];
int t[N];
int n;
typedef pair<int, pair<int,int>> PII;
int work(int idx, int time)
{
int ans = 0;
priority_queue<PII> qq;
for(int i = 0; i <= idx; i++)qq.push({s[i], {i, 0}});
for(int i = 0; i < time; i++)
{
PII ele = qq.top();
qq.pop();
ans += max(ele.first, 0); //此处一定要注意不能加个负数 …… 调试半天
int temp = ele.second.second + 1;
int index = ele.second.first;
qq.push({s[index]-temp*d[index], {index, temp}});
}
return ans;
}
int main()
{
int T;
int res = 0;
cin >> n;
for(int i = 0; i < n; i++) cin >> s[i];
for(int i = 0; i < n; i++) cin >> d[i];
for(int i = 1; i < n; i++) cin >> t[i], t[i] += t[i-1];
cin >> T;
for(int i = 0; i < n; i++)res = max(res, work(i, T-t[i]));
cout << res;
return 0;
}