QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106308#6401. Classic: N Real DNA Pots24getonGXUWA 35ms3660kbC++142.1kb2023-05-17 13:03:402023-05-17 13:03:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-17 13:03:43]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:3660kb
  • [2023-05-17 13:03:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define debug(x...) cerr << (#x) <<" -> ", err(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())

#define fi first
#define se second
#define endl '\n'
#define int long long

void err() {
	cerr << '\n';
}
template<class T, class... Ts>
void err(const T &A, const Ts &... other) {
	cerr << (A) << ' ';
	err(other...);
}
using PII = pair<int, int>;

const int N = 2e6 + 10, INF = 0x3f3f3f3f;
const int mod = 998244353;

int n, k;
int x[N], y[N];
long double a[N], q[N];

void solve() {
	cin >> n >> k;
	for(int i = 0; i < n; i ++ ) cin >> x[i] >> y[i];
	long double _l = -INF, _r = INF;
	for(int _i = 0; _i <= 1e6; _i ++ ){
		long double _mid = (_l + _r)/2;
		for(int i = 0; i < n; i ++ ) a[i] = y[i] - _mid*x[i];
		int len = 0;
	    for(int i = 0; i < n; i ++ ){
	        int l = 0, r = len;
	        while(l < r){
	            int mid = l + r + 1 >> 1;
	            if(q[mid] < a[i]) l = mid;
	            else r = mid - 1;
	        }
	        len = max(len, r + 1);
	        q[r + 1] = a[i];
	    }
	    if(len >= k) _l = _mid;
	    else _r = _mid;
	}
	cout << _l << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int ___ = 1;
	cout << fixed << setprecision(1);
	// cin >> ___;
	for (int i = 1; i <= ___; i ++) solve();
	return 0;
}
/*
*
*  ┏┓   ┏┓+ +
* ┏┛┻━━━┛┻┓ + +
* ┃       ┃
* ┃   ━   ┃ ++ + + +
*  ████━████+
*  ◥██◤ ◥██◤ +
* ┃   ┻   ┃
* ┃       ┃ + +
* ┗━┓   ┏━┛
*   ┃   ┃ + + + +Code is far away from  
*   ┃   ┃ + bug with the animal protecting
*   ┃    ┗━━━┓ 神兽保佑,代码无bug 
*   ┃        ┣┓
*    ┃        ┏┛
*     ┗┓┓┏━┳┓┏┛ + + + +
*    ┃┫┫ ┃┫┫
*    ┗┻┛ ┗┻┛+ + + +
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 35ms
memory: 3596kb

input:

4 3
1 2
2 4
3 3
4 1

output:

-1.0

result:

ok found '-1.0000000', expected '-1.0000000', error '-0.0000000'

Test #2:

score: 0
Accepted
time: 16ms
memory: 3508kb

input:

2 2
1 1
5 3

output:

0.5

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #3:

score: -100
Wrong Answer
time: 16ms
memory: 3660kb

input:

2 2
222640995 547139825
489207317 725361095

output:

0.7

result:

wrong answer 1st numbers differ - expected: '0.6685813', found: '0.7000000', error = '0.0314187'