QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#79469 | #2464. Taxed Editor | chimo | WA | 2ms | 3324kb | C++ | 1.4kb | 2023-02-20 09:24:27 | 2023-02-20 09:24:29 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int INF = 1e9;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
int n,m;
typedef long long ll;
#define data data_
const int N = 1e6;
struct data{
ll len, ddl;
} p[N];
ll q[N];
ll h = 1, t = 1;
ll getpos(ll id, ll spd){
ll l = 0, r = t ,res = -1;
while (l<=r) {
ll mid = (l+r) >> 1;
if (q[mid] + p[id].len <= p[id].ddl * spd) {
l = mid + 1;
res = mid;
} else {
r = mid -1;
}
}
return res;
}
bool check(ll spd){
h = t = 0;
q[h] =0;
rep(i,1,n) {
ll pos = getpos(i ,spd);
if (pos == -1) continue;
ll cur = p[i].len + q[pos];
if (pos == t || q[pos + 1] >= cur){
q[pos + 1] = cur;
if (pos == t) t ++;
}
}
rep(i,0,t) q[i] = 0;
return t >= n-m;
}
bool cmp(data a, data b) {
return (a.ddl < b.ddl) || (a.ddl == b.ddl && a.len < b.len);
}
int main(){
cin >> n >> m;
rep(i,1,n){
cin >> p[i].len >> p[i].ddl;
}
sort(p+1, p+1+n, cmp);
//rep(i,1,n) cout << p[i].len << " " << p[i].ddl <<endl;
ll l = 0, r = 1e18 ,ans = -1;
while (l<=r) {
ll mid = (l+r)>>1;
if (check(mid)) { r = mid - 1; ans = mid;} else
l = mid + 1;
}
cout << ans;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3324kb
input:
100 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
100
result:
ok single line: '100'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3324kb
input:
100 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 6...
output:
-1
result:
wrong answer 1st lines differ - expected: '1', found: '-1'