# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
529438 | wiwiho | Let's Win the Election (JOI22_ho_t3) | C++14 | 18 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define iter(a) a.begin(), a.end()
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
using namespace std;
typedef long long ll;
typedef long double ld;
using pii = pair<int, int>;
ll iceil(ll a, ll b){
return (a + b - 1) / b;
}
int n, k;
vector<int> a, b;
ld calc(int cnt){
vector<pii> tmp;
for(int i = 1; i <= n; i++){
if(b[i] == -1) continue;
tmp.eb(mp(b[i], i));
}
if(tmp.size() < cnt) return 1e87;
lsort(tmp);
vector<bool> use(n + 1);
ld ans = 0;
for(int i = 0; i < cnt; i++){
use[tmp[i].S] = true;
ans += (ld)tmp[i].F / (i + 1);
}
tmp.clear();
for(int i = 1; i <= n; i++){
if(use[i]) continue;
tmp.eb(mp(a[i], i));
}
lsort(tmp);
for(int i = 0; i < k - cnt; i++){
ans += (ld)tmp[i].F / (cnt + 1);
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
a.resize(n + 1);
b.resize(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
ld ans = 1e87;
for(int i = 0; i <= k; i++) ans = min(ans, calc(i));
cout << fixed << setprecision(20) << ans << "\n";
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... |