当前位置: 首页 > news >正文

CCPC guangdongjiangsu 2025 F

题目链接:https://codeforces.com/gym/105945/problem/F
题目背景:

       你知道自己队伍的过题数、罚时,还知道另一个队伍的每次提交记录(三种状态:ac:通过,rj:未通过,pb:封榜后提交),封榜后不知道题目提交是否正确,判断另一只队伍最少做出来几道才会超过我们。

思路:

       贪心策略:假设封榜后第一次提交就是对的即可,排序选择题目即可。

数据范围:

        1 <= T <= 100,0 <= s <= 1e3。

时间复杂度:

        O(T*s)。

ac代码:
#include <bits/stdc++.h>#define ioscc ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define me(a, x) memset(a, x, sizeof a)
#define all(a) a.begin(), a.end()
#define sz(a) ((int)(a).size())
#define pb(a) push_back(a)
using namespace std;typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<bool> vb;const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int MAX = (1ll << 31) - 1;
const int MIN = 1 << 31;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) noexcept
{for (int i = 0; i < sz(a) - 10; i++)std::cout << a[i] << ' ';return os;
}template <class T>
istream &operator>>(istream &in, vector<T> &a) noexcept
{for (int i = 0; i < sz(a) - 10; i++)std::cin >> a[i];return in;
}/* ----------------- 有乘就强转,前缀和开ll ----------------- */void solve()
{int n, a, b;cin >> n >> a >> b;vi cnt(n + 10, 0), pd;vb st(n + 10, 0);ll sum = 0; // 罚时ll tot = 0; // 过题数int m;cin >> m;while (m--){int t;char p;string op;cin >> t >> p >> op;int k = p - 'A';if (op == "ac"){if (!st[k]){st[k] = 1;sum += 1ll * t + 20ll * cnt[k];++tot;}}else if (op == "rj"){if (!st[k])++cnt[k];}else{if (!st[k]){st[k] = 1;pd.pb(1ll * t + 20ll * cnt[k]);}}}if (tot > a || (tot == a && sum < b)){cout << 0 << endl;return;}sort(all(pd));for (int i = 0; i < sz(pd); ++i){sum += pd[i];++tot;if (tot > a || (tot == a && sum < b)){cout << i + 1 << endl;return;}}cout << -1 << endl;
}int main()
{ioscc;int T;cin >> T;while (T--)solve();return 0;
}

http://www.xdnf.cn/news/936433.html

相关文章:

  • 【创新算法】改进深度优先搜索算法配合二进制粒子群的配电网故障恢复重构研究
  • 食养有方:进行性核上性麻痹患者的健康饮食指南
  • 解决SQL Server SQL语句性能问题(9)——SQL语句改写(2)
  • Linux系统防火墙之iptables
  • 工作记录 2017-08-01
  • 若依框架项目前缀配置
  • 如何在最短时间内提升打ctf(web)的水平?
  • Python安装使用教程
  • 实验三:VGA显示实验
  • JavaScript 数据类型详解
  • Razor编程中@Html的方法使用大全
  • Day25 异常处理
  • sizeof 与strlen的区别
  • Puppeteer测试框架 - Node.js
  • 解决transformers.adapters import AdapterConfig 报错的问题
  • Java中的抽象类
  • 【Redis】持久化
  • Redis知识体系
  • 【深度学习】表示学习:深度学习的数据解构与重构艺术
  • Effective Java 第三版 第二三章总结
  • Selenium自动化操作
  • Java中双端队列的多种实现类详解
  • 力扣面试150题--课程表
  • LabVIEW多道心电记录仪
  • 【靶场】XXE-Lab xxe漏洞
  • Java严格模式withResolverStyle解析日期错误及解决方案
  • PLC入门【1】PLC的简单介绍(教学软件:FX-TRN-BEG-C)
  • Spring Boot中Bean注入方式对比与最佳实践
  • AUTOSAR实战教程--开放式通用DoIP刷写工具OpenOTA开发计划
  • 分类场景数据集大全「包含数据标注+训练脚本」 (持续原地更新)