mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-30 15:56:27 +00:00
parent
f2d3f9b475
commit
beaef8d0d2
62
S2OJ/1603/1603.cpp
Normal file
62
S2OJ/1603/1603.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <tuple>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
bool work() {
|
||||||
|
int n;
|
||||||
|
long long k;
|
||||||
|
std::vector<std::pair<long long, long long>> up, down;
|
||||||
|
|
||||||
|
cin >> n >> k;
|
||||||
|
|
||||||
|
for (int i = 1, a, b; i <= n; i++) {
|
||||||
|
cin >> a >> b;
|
||||||
|
|
||||||
|
if (b - a >= 0) up.emplace_back(a, b);
|
||||||
|
else down.emplace_back(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(up.begin(), up.end(), [&](const auto &a, const auto &b) {
|
||||||
|
return a.first < b.first;
|
||||||
|
});
|
||||||
|
|
||||||
|
std::sort(down.begin(), down.end(), [&](const auto &a, const auto &b) {
|
||||||
|
return a.second > b.second;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto o : up) {
|
||||||
|
k -= o.first;
|
||||||
|
|
||||||
|
if (k <= 0) return false;
|
||||||
|
|
||||||
|
k += o.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto o : down) {
|
||||||
|
k -= o.first;
|
||||||
|
|
||||||
|
if (k <= 0) return false;
|
||||||
|
|
||||||
|
k += o.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
int t;
|
||||||
|
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
while (t--) cout << (work() ? "YES" : "NO") << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
S2OJ/1603/data/ex_tower1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/ex_tower6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/ex_tower6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/std.cpp
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/std.cpp
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/tower9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/tower9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1603/data/val.cpp
(Stored with Git LFS)
Normal file
BIN
S2OJ/1603/data/val.cpp
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user