| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 914896 | andrei_iorgulescu | Let's Win the Election (JOI22_ho_t3) | C++14 | 842 ms | 2800 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
#define int long long
int n,k;
ld m;
ld a[505],b[505];
ld v[505];
int better(int x,int y,ld t)
{
ld p1 = v[y] + b[x] / t,p2 = v[x] + b[y] / t;
//cout << x << ' ' << y << ' ' << t << ' ' << p1 << ' ' << p2 << endl;
if (p1 < p2)
return x;
//cout << y << endl;
return y;
}
ld solve(int pos,vector<int>ids)
{
if (pos == m + 1)
{
vector<ld>as;
for (auto it : ids)
as.push_back(v[it]);
sort(as.begin(),as.end());
ld adg = 0;
for (int i = 0; i < k - m + 1; i++)
adg += as[i];
return adg;
}
int opt = 0;
for (int i = 1; i < ids.size(); i++)
{
int bt = better(ids[i],ids[opt],pos - 1);
if (bt == ids[i])
opt = i;
}
//cout << opt << ' ' << ids[opt] << endl;
ld pz = pos - 1;
ld adg = b[ids[opt]] / pz;
vector<int>newids;
for (int i = 0; i < opt; i++)
newids.push_back(ids[i]);
for (int i = opt + 1; i < ids.size(); i++)
newids.push_back(ids[i]);
return adg + solve(pos + 1,newids);
}
signed main()
{
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
for (int i = 1; i <= n; i++)
if (b[i] == -1)
b[i] = 1e9;
ld ans = 1e9;
for (m = 1; m <= k; m++)
{
///m oameni workpower, apoi doar merg prin orase
for (int i = 1; i <= n; i++)
v[i] = a[i] / m;
vector<int>ids;
for (int i = 1; i <= n; i++)
ids.push_back(i);
ld cur = solve(2,ids);
//cout << cur << endl;
ans = min(ans,cur);
}
cout << setprecision(5) << fixed;
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
