今晚F不过样例求调/How F/D why WA before
  • 板块学术版
  • 楼主Vitamin_B
  • 当前回复7
  • 已保存回复8
  • 发布时间2024/9/29 00:17
  • 上次更新2024/9/29 14:45:41
查看原帖
今晚F不过样例求调/How F/D why WA before
743373
Vitamin_B楼主2024/9/29 00:17

今晚F不过样例求调:

# include <bits/stdc++.h>

# define I return

# define AK 0

# define IOI ;

using namespace std;

typedef long long ll;

typedef pair <int, int> pii;

struct node {

	int y, k;

	ll v;

	bool operator < (const node& a) const {

		return v < a.v;

	}

} ;

int n, m, x, y;

ll dp[3005], a[3005][3005];

priority_queue <node> q[3005];

int main () {

	ios::sync_with_stdio (0);

	cin.tie (0);

	cout.tie (0);

	cin >> n >> m;

	while (n --)
		cin >> x >> y, q[x].push ({y, 1, y - 1});

	for (int i = 1; i <= m; ++ i)
		if (! q[i].empty ())
			for (int j = 1; j * i <= m; ++ j) {

				node x = q[i].top ();

				q[i].pop ();

				a[i][j] = x.v + a[i][j - 1];
//				cerr << i << ',' << j << ':' << a[i][j] << '\n';
				++ x.k, x.v = x.k * (ll) (x.y - x.k) - x.v;

				q[i].push (x);

			}

	for (int i = 1; i <= m; ++ i)
		if (! q[i].empty ()) //{
			for (int j = m; j; -- j)
				for (int k = 1; k * i <= j; ++ k)
					dp[j] = max (dp[j], dp[j - k * i] + a[i][k]);
//			for (int j = 1; j <= m; ++ j) cerr << i << ',' << j << ':' << dp[j] << '\n';
//		}

	cout << dp[m];

	I AK IOI

}

How F


2024/9/29 00:17
加载中...