P5661 只得了30分,求调,谢谢
  • 板块题目总版
  • 楼主Aiden_H
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/3/20 11:15
  • 上次更新2024/3/20 16:46:12
查看原帖
P5661 只得了30分,求调,谢谢
1078683
Aiden_H楼主2024/3/20 11:15
#include <iostream>
#include <queue>
using namespace std;
struct yh { long long pc, tm; };
int main ( )
{
	queue <yh> tkt; //ticket
	yh tkto;
	long long n, pc, tm, ans = 0;
	bool bs, f;
	cin >> n;
	while(n--) {
		f = true;
		cin >> bs >> pc >> tm;
		tkto.pc = pc;
		tkto.tm = tm;
		if (!bs) { 
			ans += pc; 
			tkt.push (tkto); 
			continue; 
		}
		else {
			while (!tkt.empty ( )) {
				if ((tm - tkt.front ( ).tm <= 45) && (pc <= tkt.front ( ).pc)) {
					tkt.pop ( );
					f = false;
					break;
				}
				else if ((tm - tkt.front ( ).tm > 45) || (pc > tkt.front ( ).pc)) {
					if (!(tm - tkt.front ( ).tm <= 45)) {
						tkt.pop ( );
					}
				}
			}
			if (f)ans += pc;
		}
	}
	cout << ans;
}
2024/3/20 11:15
加载中...