QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#795250#9599. Dragon BloodlineLoxilanteWA 0ms3648kbC++201.6kb2024-11-30 18:57:472024-11-30 18:57:47

Judging History

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

  • [2024-11-30 18:57:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2024-11-30 18:57:47]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define int ll
using namespace std;
typedef long long ll;
template<typename tn = int> tn next(void) { tn k; cin>>k; return k; }
#ifndef LOCAL
#define D(...) 0
#define I(...) 0
#endif
const int U = 1.2e5;
int a[U], b[U], n, k;
bool check(int mul)
{
    priority_queue<int> pq;
    rep(i, 0, n) pq.push(a[i]*mul);
    vector<int> bt;
    rep(i, 0, k) bt.push_back(b[i]);

    rev(i, k-1, 0) while(bt[i] && pq.top() > 0)
    {
        int t = pq.top(), g = min(bt[i], max(1LL, t/(1<<i))); pq.pop();
        t -= g*(1<<i);
        bt[i] -= g;
        pq.push(t);
    }

    return pq.top() <= 0;
}
signed main(void)
{
    #ifdef LOCAL
//	freopen("C:\\Users\\Loxil\\Desktop\\IN.txt", "r", stdin);
//	freopen("C:\\Users\\Loxil\\Desktop\\OUT.txt", "w", stdout);
    #endif
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int T = next();
    while(T--)
    {
        cin>>n>>k;
        rep(i, 0, n) cin>>a[i];
        rep(i, 0, k) cin>>b[i];

        int l = 0, r = 1.1e9;
        while(l < r)
        {
            int mid = l+r+1>>1;
            if (check(mid)) l = mid;
            else r = mid-1;
        }
        cout<<l<<endl;
    }
    
    return 0;
}
/*
1
1 20
1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3636kb

input:

6
4 3
1 2 3 4
4 4 4
3 2
1 1 1
1 7
3 4
6 6 2
1 1 5 5
3 5
3 1 1
1 1 1 1 1
4 5
1 9 9 8
2 2 2 3 1
5 4
1 3 1 7 1
4 1 5 2

output:

2
4
4
5
2
3

result:

ok 6 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3648kb

input:

1
1 20
1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

output:

1100000000

result:

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