照着题解写但样例都不能过……
查看原帖
照着题解写但样例都不能过……
1047798
nahida_badminton楼主2024/3/31 21:37

如题

#include <bits/stdc++.h>
using namespace std;
int n, ans = 0, y, p, t, start = 0, tail = 0;
bool f = false;

struct S{
	int a, b, c;
}s[100002];

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> y >> p >> t;
		if (y){
			f = 0;
			while (start < tail && s[start].b < t) start++;
			for (int j = start; j < tail; j++){
				if (s[j].a >= p && s[j].c){
					s[j].c = 0;
					f = 1;
					break;
				}
				if (f == 0) ans += p;
			}
		} else {
			s[tail].a = p, s[tail].b = t + 45, s[tail].c = 1;
			ans += p;
			tail++;
		}
	}
	cout << ans << '\n';
    return 0;
}

2024/3/31 21:37
加载中...