QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#233654#6401. Classic: N Real DNA Potsucup-team963RE 0ms0kbC++141.3kb2023-10-31 20:54:272023-10-31 20:54:27

Judging History

你现在查看的是最新测评结果

  • [2023-10-31 20:54:27]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-10-31 20:54:27]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)

using namespace std;

const int N = 1e5 + 10;
int x[N], y[N], rnk[N], f[N], n, k;
double g[N], tg[N];
int c[N];
inline int add(int x, int y) {
  for(; x <= n; x += x & (-x)) c[x] = max(c[x], y);
}
inline int qry(int x) {
  int val = 0;
  for(; x; x -= x & (-x)) val = max(val, c[x]);
  return val;
}
inline bool check(double k0) {
  rep(i,1,n) tg[i] = g[i] = y[i] - k0 * x[i];
  sort(tg + 1, tg + n + 1);
  int tn = unique(tg + 1, tg + n + 1) - tg - 1;
  rep(i,1,n) rnk[i] = lower_bound(tg + 1, tg + tn + 1, g[i]) - tg;
  // cout << k0 << ',' << tn << endl;
  // rep(i,1,n) cout << g[i] << ' ';
  // cout << endl;
  // rep(i,1,n) cout << rnk[i] << ' ';
  // cout << endl;
  rep(i,1,n) c[i] = 0;
  int ans = 0;
  rep(i,1,n) {
    ans = max(ans, f[i] = qry(rnk[i]) + 1);
    add(rnk[i], f[i]);
  }
  // cout << "ans = " << ans << endl;
  return ans >= k;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  rep(i,1,n) cin >> x[i] >> y[i];
  double L = -1e9, R = 1e9;
  for(int cnt = 1; cnt <= 100; ++ cnt) {
    double mid = (L + R) / 2;
    if(check(mid)) L = mid;
    else R = mid;
  }
  cout.setf(ios::fixed);
  cout.precision(12);
  cout << L << endl;
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

4 3
1 2
2 4
3 3
4 1

output:


result: