답안 #729296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729296 2023-04-23T18:25:53 Z tch1cherin Let's Win the Election (JOI22_ho_t3) C++17
11 / 100
2500 ms 320 KB
#include <bits/stdc++.h>
using namespace std;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  vector<int> order_a(n), order_b(n);
  iota(order_a.begin(), order_a.end(), 0);
  iota(order_b.begin(), order_b.end(), 0);
  sort(order_a.begin(), order_a.end(), [&](int i, int j) {
    return a[i] < a[j];
  });
  long double ans = 1e18;
  do {
    for (int max_c = 0; max_c <= n; max_c++) {
      int c = 1, cnt = 0;
      long double res = 0;
      vector<bool> used(n, false);
      for (int i : order_b) {
        if (b[i] != -1 && c <= max_c) {
          res += (long double)b[i] / c;
          c++;
          cnt++;
          used[i] = true;
        }
      }
      for (int i : order_a) {
        if (cnt < k && !used[i]) {
          res += (long double)a[i] / c;
          cnt++;
        }
      }
      if (cnt >= k) {
        ans = min(ans, res);
      }
    }
  } while (next_permutation(order_b.begin(), order_b.end()));
  cout << ans << "\n";
}

int main() {
  cout << fixed << setprecision(9);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2552 ms 212 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2552 ms 212 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 3 ms 320 KB Output is correct
4 Correct 3 ms 316 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 2 ms 316 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 3 ms 320 KB Output is correct
4 Correct 3 ms 316 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 2 ms 316 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Execution timed out 2555 ms 212 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 3 ms 320 KB Output is correct
4 Correct 3 ms 316 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 2 ms 316 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Execution timed out 2555 ms 212 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2535 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2552 ms 212 KB Time limit exceeded
6 Halted 0 ms 0 KB -