QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#732022#9599. Dragon BloodlineyzhxWA 0ms3616kbC++201.9kb2024-11-10 12:45:232024-11-10 12:45:23

Judging History

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

  • [2024-11-10 12:45:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-11-10 12:45:23]
  • 提交

answer

 #include <iostream>
 #include <cstring>
 #include <algorithm>
 #include <queue>
 using namespace std;
 #define int long long
 const int N = 5e4 + 10;
 int n, k, a[N], b[15], c[15], d[15];
 bool check(int mid) {
     for(int i = 0; i <= 25; i ++ ) c[i] = 0;
     for(int i = 0; i <= 25; i ++ ) d[i] = b[i];
     priority_queue<int> q;
     for(int i = 1; i <= n ; i ++ ) {
         int x = mid * a[i];
         q.push(x);
     }
     for(int i = 10; ~i ; i -- ) {
         if(q.size() && q.top() <= (1 << i) && d[i]) {
             q.pop();
             d[i] -- ;
         }
         while(q.size() && q.top() >= (1 << i) && d[i]) {
             int t = q.top();
             int tt = t / (1 << i);
             int ttt = min(tt, d[i]);
             tt -= ttt, d[i] -= ttt;
             q.pop();
             if(t - ttt * (1 << i) == 0) continue;
             q.push(t - ttt * (1 << i));
             
         }
         while(q.size() && q.top() <= (1 << i) && d[i]) {
             q.pop();
             d[i] -- ;
         }
     }
     int j = 10;
     while(q.size()) {
         if(j <= 0) break;
         while(j >= 0 && !d[j]) j -- ;
         while(q.size() && j >= 0 && (1 << j) > q.top() && d[j]) {
             if(j < 0) break;
             d[j] -- ;
             q.pop();
         }
         j -- ;
     }
     if(q.size()) return false;
     return true;
 }
 void solve() {
     cin >> n >> k;
     memset(b, 0, sizeof b);
     int per = 0, sum = 0;
     for(int i = 1; i <= n ; i ++ ) cin >> a[i], per += a[i];
     for(int i = 0; i < k ; i ++ ) cin >> b[i], sum += (1 << i) * b[i];
     
     int l = 0, r = sum / per;
     while(l < r) {
         int mid = l + r + 1 >> 1;
         if(check(mid)) l = mid;
         else r = mid - 1; 
     }
     cout << l << endl;
 }
 signed main() {
     ios::sync_with_stdio(0), cin.tie(0);
     int T = 1;
     cin >> T;
     while(T -- ) solve();
     return 0;
 }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

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:

0
0
0
0
0
0

result:

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