QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#368921 | #8511. Greek Casino | PetroTarnavskyi# | TL | 0ms | 0kb | C++20 | 1.0kb | 2024-03-27 18:06:40 | 2024-03-27 18:06:41 |
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