QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#368928 | #8516. LED Matrix | PetroTarnavskyi# | WA | 1ms | 3776kb | C++20 | 1.2kb | 2024-03-27 18:13:41 | 2024-03-27 18:13:43 |
Judging History
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];
});
db tta = 0, ttb = 0;
FOR (i, 0, n)
{
ttb += b[i] * (u[i] + w[i]);
}
int j = 0;
while (ttb > tb || (j < SZ(idx) && a[idx[j]] - b[idx[j]] < 0))
{
int i = idx[j];
db x = 0;
if (a[i] - b[i] < 0)
x = min(db(u[i] + w[i]), db(ta - tta) / a[i]);
else
x = max(db(0), db(ttb - tb) / b[i]);
tta += x * a[i];
ttb -= x * b[i];
j++;
}
cout << fixed << setprecision(15) << tta + ttb << '\n';
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3776kb
input:
6 6 6 ****** --*--- ****** -**--- ****** ****** ****** ****** ****** -**--- *****- --*---
output:
0.000000000000000
result:
wrong answer 1st words differ - expected: 'N', found: '0.000000000000000'