QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#682204#9529. Farm Managementucup-team2432#WA 0ms3648kbC++201.7kb2024-10-27 14:24:282024-10-27 14:24:28

Judging History

你现在查看的是最新测评结果

  • [2024-10-27 14:24:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2024-10-27 14:24:28]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(vec) ((ll)vec.size())
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using db = double;
using i128 = __int128;
#define Emu Smile
using namespace std;

const int P = 998244353;

void yes() { cout << "Yes\n"; }
void no() { cout << "No\n"; }

void chmax(auto &a,auto b) { if (a < b) a = b; }
void chmin(auto &a,auto b) { if (a > b) a = b; }

void solve() {
	int n; ll T; cin >> n >> T;
	vector<array<ll,3>> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	sort(all(a), [&](array<ll,3> x, array<ll,3> y){
		return x[0] > y[0];
	});
	ll suml = 0, suml_w = 0;
	for (int i = 0; i < n; ++i) {
		suml += a[i][1];
		suml_w += a[i][1] * a[i][0];
	}
	ll ret = 0;
	{
		ll t = T - suml, w = suml_w;
		for (int i = 0; i < n; ++i) {
			ll mt = min(t, a[i][2] - a[i][1]);
			w += mt * a[i][0];
			t -= mt;
			if (!t) break;
		}
		chmax(ret, w);
	}
	vector<ll> preT(n+1), preT_w(n+1);
	for (int i = 0; i < n; ++i) {
		preT[i+1] = preT[i] + a[i][2] - a[i][1];
		preT_w[i+1] = preT_w[i] + (a[i][2] - a[i][1]) * a[i][0];
	}
	for (int i = 0; i < n; ++i) {
		ll t = T - suml + a[i][1], w = suml_w - a[i][1] * a[i][0];
		ll it = upper_bound(all(preT), t) - preT.begin() - 1;
		chmin(it, i);
		t -= preT[it], w += preT_w[it] + a[i][0] * t;
		chmax(ret, w);
	}
	cout << ret << '\n';
}

int main() {

	ios::sync_with_stdio(false);
	cin.tie(nullptr);

//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);

	cout << fixed << setprecision(10);

//	init();

	int OuO = 1;
//	cin >> OuO;
	for (int piastic = 0; piastic < OuO; ++piastic) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

5 17
2 3 4
6 1 5
8 2 4
4 3 3
7 5 5

output:

109

result:

ok single line: '109'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3548kb

input:

12 62
503792 9 10
607358 1 3
600501 10 10
33249 4 4
774438 6 6
197692 3 6
495807 8 8
790225 5 9
77272 3 8
494819 4 9
894779 3 9
306279 5 6

output:

34859047

result:

wrong answer 1st lines differ - expected: '35204500', found: '34859047'