/ WOJ /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 2ms 480.0 KiB
#2 Wrong Answer 1ms 524.0 KiB
#3 Wrong Answer 1ms 536.0 KiB
#4 Wrong Answer 1ms 508.0 KiB
#5 Wrong Answer 1ms 472.0 KiB
#6 Wrong Answer 1ms 548.0 KiB
#7 Wrong Answer 1ms 324.0 KiB
#8 Wrong Answer 1ms 344.0 KiB
#9 Wrong Answer 1ms 320.0 KiB
#10 Wrong Answer 1ms 476.0 KiB

代码

#include <bits/extc++.h>
#define endl '\n'
typedef long long ll;
#define int ll
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

void Main() {
  int n, u, k, hq;
  cin >> n >> u >> k >> hq;
  struct ly {
    int hacked = 0, hack = 0, blood = 0, sy;
    bool alive() { return blood; }
    bool chk(int k) { return hacked <= k; }
    void attack(int a, int mx) {
      if (!alive() || hacked > mx) {
        return;
      }
      if (hacked) {
        ++hacked;
        blood = max(blood - (a >> 1), 0ll);
      } else {
        ++hacked;
        blood = max(blood - a, 0ll);
      }
    }
    bool operator<(ly b) const {
      if (blood != b.blood) {
        return blood < b.blood;
      } else if (hack != b.hack) {
        return hack < b.hack;
      } else {
        return sy < b.sy;
      }
    }
  };
  vector<ly> enemy(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> enemy[i].hack >> enemy[i].blood;
    enemy[i].sy = i;
  }
  set<ly> pq;
  set<ly> lv;
  for (int i = 1; i <= n; ++i) {
    pq.insert(enemy[i]);
    lv.insert(enemy[i]);
  }
  while (lv.size() && hq) {
    auto tmp = *pq.begin(), c = tmp;
    tmp.attack(u, k);
    if (!tmp.alive()) {
      if (pq.count(c))
        pq.erase(c);
      if (lv.count(c))
        lv.erase(c);
    } else if (!tmp.chk(k)) {
      if (pq.count(c))
        pq.erase(c);
    }
    if (lv.size())
      hq = max(hq - ((*lv.rbegin()).hack), 0ll);
  }
  cout << n - lv.size() << endl;
}

signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    Main();
  }
  return 0;
}

信息

递交者
类型
递交
题目
P1000 云剪贴板
题目数据
下载
语言
C++
递交时间
2025-03-29 14:23:31
评测时间
2025-03-29 14:23:31
评测机
分数
0
总耗时
17ms
峰值内存
548.0 KiB