RT
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#define MAXN 250000
#define QWQ cout << "QWQ" << endl;
using namespace std;
struct node {
long long val;
int id;
node(long long V, int I) {
val = V, id = I;
}
bool operator < (const node &other) const {
return val < other.val;
}
};
vector <int> vec;
long long a[MAXN + 10], b[MAXN + 10];
bool vis[MAXN + 10];
int main() {
priority_queue <node> que;
int n; cin >> n;
for(int p = 1; p <= n; p++)
cin >> a[p];
long long ans = 0, tot = 0;
for(int p = 1; p <= n; p++) {
cin >> b[p];
tot += a[p];
if(tot >= b[p]) {
tot -= b[p];
ans++;
que.push(node(b[p], p));
}
else if(!que.empty() && tot + que.top().val >= b[p]) {
tot = tot + que.top().val - b[p];
que.push(node(b[p], p)); que.pop();
}
}
while(!que.empty()) {
vec.push_back(que.top().id);
que.pop();
}
sort(vec.begin(), vec.end());
cout << ans << endl;
for(int p = 0; p < ans; p++)
cout << vec[p] << ' ';
}
被毒到了,一直调不对/kk
求助/kel