神奇20分,WA,RE都有,谁能帮忙看看?
查看原帖
神奇20分,WA,RE都有,谁能帮忙看看?
895690
gghack_Nythix楼主2023/1/19 16:15

rt

#include <bits/stdc++.h>
#define int long long
using namespace std;
int sum[10000000],a[10000000],homo = 1,n,m,x,y,ans;
signed main()
{
	cin >> n >> m;
	for(int i = 1;i <= n;++i){
		cin >> x >> y;
		a[x] += y;
		homo = max(homo,x);
	}
	for(int i = 1;i <= homo;++i){
		sum[i] = sum[i - 1]+a[i];
	}
	ans = -11;
	for(int i = 1;i <= homo;++i){
		ans = max(ans,sum[i] - sum[i - m]);
	}
	cout << ans;
	return 0;
}
2023/1/19 16:15
加载中...