QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#511027 | #3404. Download Manager | PetroTarnavskyi# | AC ✓ | 74ms | 4100kb | C++20 | 1.3kb | 2024-08-09 15:21:57 | 2024-08-09 15:21:58 |
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 t, n, b;
void solve()
{
vector<pair<db, int>> allFiles(t);
for (auto& [s, p] : allFiles)
{
cin >> s >> p;
p = 100 - p;
}
sort(ALL(allFiles));
vector<db> curFiles;
int ptr = 0;
while (ptr < min(n, t))
{
auto [s, p] = allFiles[ptr++];
curFiles.PB(p / 100.0 * s);
}
db ans = 0;
while (!curFiles.empty())
{
auto it = min_element(ALL(curFiles));
db mn = *it;
ans += mn / b * SZ(curFiles);
curFiles.erase(it);
for (db& x : curFiles)
x -= mn;
if (ptr < t)
{
auto [s, p] = allFiles[ptr++];
curFiles.PB(p / 100.0 * s);
}
}
cout << ans << "\n" << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(2);
for (int tc = 1; ; tc++)
{
cin >> t >> n >> b;
if (t == 0)
return 0;
cout << "Case " << tc << ": ";
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 74ms
memory: 4100kb
input:
811 4 121 3826.54 95 445.38 99 6204.15 1 742.96 99 7660.59 95 7623.04 36 9395.56 74 5217.92 64 10337.50 41 9416.15 78 1434.81 61 6284.21 25 5777.48 35 6476.33 95 5798.93 81 9586.30 75 3829.00 46 6804.11 48 339.48 30 8000.52 64 1360.48 96 152.40 91 1695.44 56 2185.38 39 7274.79 6 7273.17 98 5003.76 8...
output:
Case 1: 18144.21 Case 2: 32334.66 Case 3: 22793.20 Case 4: 8700.69 Case 5: 30243.73 Case 6: 597533.19 Case 7: 256141.10 Case 8: 65991.76 Case 9: 90311.43 Case 10: 194197.53
result:
ok 19 lines