样例过了但报0了大佬帮忙看看
查看原帖
样例过了但报0了大佬帮忙看看
1098401
15925386737hzy楼主2024/8/16 09:45
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int t1[N];
int pe;
int sum;
int ans[N];
int o ;

int main() {
	int n;
	cin >> n;
	int cc;
	for (int i = 1; i <= n; i++) {
		cin >> cc >> pe >> t1[i];
		if (cc == 0) {
			sum += pe;
			ans[o] = t1[i];
			o++;
		}
		if (cc == 1) {
			for (int j = 0; j < o; j++) {
				if (t1[i] - ans[j] <= 45) {
					if (ans[i] != -1) {
						ans[i] = -1;
						o = 0;
						break;
					}
				} else {
					sum += pe;
				}
			}
		}
	}
	cout << sum;
	return 0;
}
2024/8/16 09:45
加载中...