求助一道题
  • 板块灌水区
  • 楼主Rutledge
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/8/3 19:41
  • 上次更新2023/11/3 06:05:38
查看原帖
求助一道题
1046203
Rutledge楼主2023/8/3 19:41

我在某某OJ上过了一道CSP的题目,但在洛谷上只拿了30分,题目的数据范围和题目内容也应该一样的,有没有人帮我看看是什么问题 :

#include <bits/stdc++.h>
using namespace std;
struct Node {
	bool Flag;
	int Price;
	int Time;
} a[100050];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, ans = 0, head = 1, tail = 1;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		bool check;
		int price, _time;
		cin >> check >> price >> _time;
		if (!check) {
			ans += price;
			a[++ tail].Price = price;
			a[tail].Time = _time;
		} else {
			bool flag = 0;
			for (; head <= tail && a[head].Time + 45 <= _time; head ++);
			for (int j = head; j <= tail; j ++) {
				if (a[j].Price >= price && !a[j].Flag) {
					flag = 1;
					a[j].Flag = 1;
					break;
				}
			}
			if (!flag)
				ans += price;
		}
	}
	cout << ans;
	return 0;
}

题目是P5661 [CSP-J 2019] 公交换乘

2023/8/3 19:41
加载中...