QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368921#8511. Greek CasinoPetroTarnavskyi#TL 0ms0kbC++201.0kb2024-03-27 18:06:402024-03-27 18:06:41

Judging History

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

  • [2024-03-27 18:06:41]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-03-27 18:06:40]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second 

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	VI a(n), u(n), b(n), w(n);
	FOR (i, 0, n)
	{
		cin >> a[i] >> u[i] >> b[i] >> w[i];
	}
	LL ta = 0, tb = 0;
	FOR (i, 0, n)
	{
		ta += a[i] * u[i];
		tb += b[i] * w[i];
	}
	VI idx(n);
	iota(ALL(idx), 0);
	sort(ALL(idx), [&](int i, int j)
	{
		return a[i] - b[i] < a[j] - b[j];
	});
	LL ans = 0;
	FOR (i, 0, n)
	{
		ans += b[i] * (u[i] + w[i]);
	}
	LL tta = 0, ttb = ans;
	int j = 0;
	while (ttb > tb || (j < SZ(idx) && a[idx[j]] - b[idx[j]] < 0))
	{
		int i = idx[j];
		
		
		
		j++;
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3
1 1 1

output:


result: