暴力出奇迹
  • 板块P1901 发射站
  • 楼主AK_heaven
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/6/11 15:00
  • 上次更新2024/6/11 19:09:55
查看原帖
暴力出奇迹
799877
AK_heaven楼主2024/6/11 15:00

AC 8 个点

#include <bits/stdc++.h>

#define L(i, a, b) for(int i = (a); i <= (b); i++)
#define R(i, a, b) for(int i = (a); i >= (b); i--)
#define pii pair<int, int>
#define ll long long
#define vi vector<int>
using namespace std;

const int N = 1e6 + 10;

int p[N], ans, n, e[N], se[N];

int find1(int x, int s) {
	R(i, s, 1) if(p[i] > x) return i;
	return 0;
}

int find2(int x, int s) {
	L(i, s, n) if(p[i] > x) return i;
	return 0;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	L(i, 1, n) cin >> p[i] >> e[i];
	int x = 0, y = 0;
	L(i, 1, n) {
		x = find1(p[i], i-1);
		y = find2(p[i], i+1);
		se[x] += e[i];
		se[y] += e[i];
	}
	cout << *max_element(se+1, se+n+1);
	return 0;
}

qwq

2024/6/11 15:00
加载中...