QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#79467#2464. Taxed EditorchimoWA 2ms3376kbC++1.4kb2023-02-20 09:23:072023-02-20 09:23:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-20 09:23:10]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3376kb
  • [2023-02-20 09:23:07]
  • 提交

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 = 2 ,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: 0
Wrong Answer
time: 2ms
memory: 3376kb

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:

-1

result:

wrong answer 1st lines differ - expected: '100', found: '-1'