16 周训练
发布日期:2021-05-14 09:16:17 浏览次数:18 分类:精选文章

本文共 3985 字,大约阅读时间需要 13 分钟。

������������������������

������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

������������������

������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

#include 
#include
#include
#include
using namespace std;
struct Node {
int s, e;
};
bool cmp(Node a, Node b) {
return a.e < b.e;
}
int main() {
int n;
cin >> n;
vector
a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i].s >> a[i].e;
}
sort(a.begin(), a.end(), cmp);
int ans = 1;
int end = a[0].e;
for (int i = 1; i < n; ++i) {
if (a[i].s > end) {
ans++;
end = a[i].e;
}
}
// ...���������������������������������
cout << ans << endl;
return 0;
}

������������������������������������������������������������������������������������������������������������

������������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

#include 
#include
#include
using namespace std;
struct Node {
int p, e;
};
bool cmp(Node a, Node b) {
return a.p > b.p;
}
int main() {
int n;
cin >> n;
vector
a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i].e >> a[i].p;
a[i].e++; // ���������������������1���������������������������������������
}
sort(a.begin(), a.end(), cmp);
int vis[100005] = {0};
int ans = 0;
for (int i = 0; i < n; ++i) {
for (int j = a[i].e; j > 0; --j) {
if (vis[j] == 0) {
vis[j] = 1;
ans += a[i].p;
break;
}
}
}
cout << ans << endl;
return 0;
}

���������������������������������������������������������������������������������������������������������������������������

������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

#include 
#include
#include
#include
using namespace std;
struct Node {
int v;
bool operator<(Node x) {
return v < x.v;
}
};
int main() {
int n, h;
cin >> n >> h;
vector
d(n), t(n);
for (int i = 0; i < n; ++i) {
d[i] = ...; // ������������������
t[i] = ...;
}
h *= 12; // ���������������
priority_queue
q; for (int i = 1; i <= n; ++i) { q.push(Node{s[i].v, i}); } int ans = 0, now = 0; while (!q.empty() && h > 0) { node a = q.top(); q.pop(); h -= t[a.num - 1]; // ������������ if (a.v <= 0) continue; now += a.v; q.push({a.v / 3, a.num}); // ������������������������ } ans = max(now, ans); // ...��������������������������������� cout << ans << endl; return 0; }

���������������������������������������������������������������������������������������������������������������������������������

������������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

上一篇:ACM训练总结
下一篇:257 div2 C:Jzzhu and Chocolate

发表评论

最新留言

感谢大佬
[***.8.128.20]2025年04月27日 06时24分55秒