求助!#6RE
查看原帖
求助!#6RE
375350
zhouyujie楼主2022/11/22 20:13
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXQ = 1e6;
pair<int, int> a[MAXQ];
signed main() {
	int textcase;
	cin >> textcase;
	int tail = 0, head = 1;
	for(int i = 1; i <= textcase; i++) {
		int op, c, x;
		cin >> op;
		if(op == 1) {
			cin >> x >> c;//c个x进队列 
			a[++tail].first = x;
			a[tail].second = c;
		}else if(op == 2) {
			cin >> c;//c个数出队列 
			int sum = 0;
			while(c >= a[head].second) {
				c -= a[head].second;
				sum += a[head].second * a[head].first;
				head++;
			}
			sum += c * a[head].first;
			a[head].second -= c;
			cout << sum << endl;
		}
	}
	return 0;
} 
2022/11/22 20:13
加载中...