QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#79470#2464. Taxed EditorchimoWA 2ms3564kbC++1.5kb2023-02-20 09:30:192023-02-20 09:30:19

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:30:19]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3564kb
  • [2023-02-20 09:30:19]
  • 提交

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++)
typedef long long ll;
ll n,m;
#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;
    }

    /*n = 100; m= 0;
    rep(i,1,n) {p[i].len = 1,p[i].ddl = i;}
    sort(p+1, p+1+n, cmp);
    */
     //rep(i,1,n) cout << p[i].len << " " << p[i].ddl <<endl;
    ll l = 0, r = 1e12 ,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: 3368kb

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: 0
Accepted
time: 2ms
memory: 3376kb

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:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

100 99
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 ...

output:

1

result:

ok single line: '1'

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 3564kb

input:

100 0
1 40
1 41
1 42
1 3
1 20
1 4
1 5
1 86
1 87
1 13
1 14
1 1
1 15
1 16
1 18
1 19
1 21
1 22
1 93
1 94
1 74
1 95
1 96
1 23
1 25
1 29
1 30
1 31
1 53
1 54
1 88
1 89
1 17
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 75
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 ...

output:

48

result:

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