Finally do another div3 again.
I'm getting rusty...
This commit is contained in:
parent
48a13b9262
commit
fddaaeba59
97
Codeforces Round 988 (Div. 3)/A. Twice.cpp
Normal file
97
Codeforces Round 988 (Div. 3)/A. Twice.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/* Problem URL: https://codeforces.com/contest/2037/problem/0 */
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define V vector
|
||||
|
||||
#define rmin(a, b) a = min(a, b)
|
||||
#define rmax(a, b) a = max(a, b)
|
||||
|
||||
#define rep(i, lim) for (size_t i = 0; i < (lim); i++)
|
||||
#define nrep(i, s, lim) for (size_t i = s; i < (lim); i++)
|
||||
|
||||
#define repv(i, v) for (auto &i : (v))
|
||||
#define fillv(v) for (auto &itr_ : (v)) { cin >> itr_; }
|
||||
#define sortv(v) sort(v.begin(), v.end())
|
||||
#define all(v) (v).begin(), (v).end()
|
||||
|
||||
using vi = vector<int>;
|
||||
using vvi = vector<vi>;
|
||||
using vvvi = vector<vvi>;
|
||||
using vvvvi = vector<vvvi>;
|
||||
|
||||
using ll = long long;
|
||||
|
||||
using vl = vector<ll>;
|
||||
using vvl = vector<vl>;
|
||||
using vvvl = vector<vvl>;
|
||||
using vvvvl = vector<vvvl>;
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<v> &vec)->ostream& {
|
||||
os << vec[0];
|
||||
for (size_t i = 1; i < vec.size(); i++) {
|
||||
os << ' ' << vec[i];
|
||||
}
|
||||
os << '\n';
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<v> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
is >> i;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<vector<v>> &vec)->ostream& {
|
||||
for (auto &i : vec) {
|
||||
os << i[0];
|
||||
for (size_t j = 1; j < i.size(); j++) {
|
||||
os << ' ' << i[j];
|
||||
}
|
||||
os << '\n';
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<vector<v>> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
for (auto &j : i) {
|
||||
is >> j;
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
while (t--) {
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
map<int, int> m;
|
||||
while (n--) {
|
||||
int i;
|
||||
cin >> i;
|
||||
m[i]++;
|
||||
}
|
||||
|
||||
int ans = 0;
|
||||
for (auto i : m) {
|
||||
ans += i.second / 2;
|
||||
}
|
||||
|
||||
cout << ans << '\n';
|
||||
}
|
||||
}
|
||||
106
Codeforces Round 988 (Div. 3)/B. Intercepted Inputs.cpp
Normal file
106
Codeforces Round 988 (Div. 3)/B. Intercepted Inputs.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
/* Problem URL: https://codeforces.com/contest/2037/problem/B */
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define V vector
|
||||
|
||||
#define rmin(a, b) a = min(a, b)
|
||||
#define rmax(a, b) a = max(a, b)
|
||||
|
||||
#define rep(i, lim) for (size_t i = 0; i < (lim); i++)
|
||||
#define nrep(i, s, lim) for (size_t i = s; i < (lim); i++)
|
||||
|
||||
#define repv(i, v) for (auto &i : (v))
|
||||
#define fillv(v) for (auto &itr_ : (v)) { cin >> itr_; }
|
||||
#define sortv(v) sort(v.begin(), v.end())
|
||||
#define all(v) (v).begin(), (v).end()
|
||||
|
||||
using vi = vector<int>;
|
||||
using vvi = vector<vi>;
|
||||
using vvvi = vector<vvi>;
|
||||
using vvvvi = vector<vvvi>;
|
||||
|
||||
using ll = long long;
|
||||
|
||||
using vl = vector<ll>;
|
||||
using vvl = vector<vl>;
|
||||
using vvvl = vector<vvl>;
|
||||
using vvvvl = vector<vvvl>;
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<v> &vec)->ostream& {
|
||||
os << vec[0];
|
||||
for (size_t i = 1; i < vec.size(); i++) {
|
||||
os << ' ' << vec[i];
|
||||
}
|
||||
os << '\n';
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<v> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
is >> i;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<vector<v>> &vec)->ostream& {
|
||||
for (auto &i : vec) {
|
||||
os << i[0];
|
||||
for (size_t j = 1; j < i.size(); j++) {
|
||||
os << ' ' << i[j];
|
||||
}
|
||||
os << '\n';
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<vector<v>> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
for (auto &j : i) {
|
||||
is >> j;
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
while (t--) {
|
||||
int size;
|
||||
cin >> size;
|
||||
vi fds(size);
|
||||
cin >> fds;
|
||||
|
||||
set<int> s;
|
||||
|
||||
int n;
|
||||
int m;
|
||||
for (auto i : fds) {
|
||||
if ((size - 2) % i != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto itr = s.find((size - 2) / i);
|
||||
if (itr != s.end()) {
|
||||
n = i;
|
||||
m = *itr;
|
||||
break;
|
||||
}
|
||||
|
||||
s.insert(i);
|
||||
}
|
||||
|
||||
cout << n << ' ' << m << '\n';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,140 @@
|
||||
/* Problem URL: https://codeforces.com/contest/2037/problem/C */
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define V vector
|
||||
|
||||
#define rmin(a, b) a = min(a, b)
|
||||
#define rmax(a, b) a = max(a, b)
|
||||
|
||||
#define rep(i, lim) for (size_t i = 0; i < (lim); i++)
|
||||
#define nrep(i, s, lim) for (size_t i = s; i < (lim); i++)
|
||||
|
||||
#define repv(i, v) for (auto &i : (v))
|
||||
#define fillv(v) for (auto &itr_ : (v)) { cin >> itr_; }
|
||||
#define sortv(v) sort(v.begin(), v.end())
|
||||
#define all(v) (v).begin(), (v).end()
|
||||
|
||||
using vi = vector<int>;
|
||||
using vvi = vector<vi>;
|
||||
using vvvi = vector<vvi>;
|
||||
using vvvvi = vector<vvvi>;
|
||||
|
||||
using ll = long long;
|
||||
|
||||
using vl = vector<ll>;
|
||||
using vvl = vector<vl>;
|
||||
using vvvl = vector<vvl>;
|
||||
using vvvvl = vector<vvvl>;
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<v> &vec)->ostream& {
|
||||
os << vec[0];
|
||||
for (size_t i = 1; i < vec.size(); i++) {
|
||||
os << ' ' << vec[i];
|
||||
}
|
||||
os << '\n';
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<v> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
is >> i;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<vector<v>> &vec)->ostream& {
|
||||
for (auto &i : vec) {
|
||||
os << i[0];
|
||||
for (size_t j = 1; j < i.size(); j++) {
|
||||
os << ' ' << i[j];
|
||||
}
|
||||
os << '\n';
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<vector<v>> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
for (auto &j : i) {
|
||||
is >> j;
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
V<bool> isprime(1e5 * 4 + 1, true);
|
||||
isprime[1] = false;
|
||||
|
||||
for (size_t i = 1; i <= (size_t)1e5 * 4; i++) {
|
||||
if (!isprime[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (size_t j = i * 2; j <= (size_t)1e5 * 4; j += i) {
|
||||
isprime[j] = false;
|
||||
}
|
||||
}
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
while (t--) {
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
vi odd;
|
||||
vi even;
|
||||
|
||||
for (size_t i = 1; i <= n; i++) {
|
||||
if (i & 1) {
|
||||
odd.push_back(i);
|
||||
} else {
|
||||
even.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
int i = odd.size() - 1;
|
||||
int j = 0;
|
||||
|
||||
while (i >= 0) {
|
||||
j = even.size() - 1;
|
||||
while (j >= 0 && isprime[odd[i] + even[j]]) {
|
||||
j--;
|
||||
}
|
||||
if (j >= 0) {
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
|
||||
if (i < 0) {
|
||||
cout << "-1\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
for (size_t k = 0; k < odd.size(); k++) {
|
||||
if (k != i) {
|
||||
cout << odd[k] << ' ';
|
||||
}
|
||||
}
|
||||
|
||||
cout << odd[i] << ' ' << even[j] << ' ';
|
||||
for (size_t k = 0; k < even.size(); k++) {
|
||||
if (k != j) {
|
||||
cout << even[k] << ' ';
|
||||
}
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
}
|
||||
125
Codeforces Round 988 (Div. 3)/D. Sharky Surfing.cpp
Normal file
125
Codeforces Round 988 (Div. 3)/D. Sharky Surfing.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
/* Problem URL: https://codeforces.com/contest/2037/problem/D */
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define V vector
|
||||
|
||||
#define rmin(a, b) a = min(a, b)
|
||||
#define rmax(a, b) a = max(a, b)
|
||||
|
||||
#define rep(i, lim) for (size_t i = 0; i < (lim); i++)
|
||||
#define nrep(i, s, lim) for (size_t i = s; i < (lim); i++)
|
||||
|
||||
#define repv(i, v) for (auto &i : (v))
|
||||
#define fillv(v) for (auto &itr_ : (v)) { cin >> itr_; }
|
||||
#define sortv(v) sort(v.begin(), v.end())
|
||||
#define all(v) (v).begin(), (v).end()
|
||||
|
||||
using vi = vector<int>;
|
||||
using vvi = vector<vi>;
|
||||
using vvvi = vector<vvi>;
|
||||
using vvvvi = vector<vvvi>;
|
||||
|
||||
using ll = long long;
|
||||
|
||||
using vl = vector<ll>;
|
||||
using vvl = vector<vl>;
|
||||
using vvvl = vector<vvl>;
|
||||
using vvvvl = vector<vvvl>;
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<v> &vec)->ostream& {
|
||||
os << vec[0];
|
||||
for (size_t i = 1; i < vec.size(); i++) {
|
||||
os << ' ' << vec[i];
|
||||
}
|
||||
os << '\n';
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<v> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
is >> i;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<vector<v>> &vec)->ostream& {
|
||||
for (auto &i : vec) {
|
||||
os << i[0];
|
||||
for (size_t j = 1; j < i.size(); j++) {
|
||||
os << ' ' << i[j];
|
||||
}
|
||||
os << '\n';
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<vector<v>> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
for (auto &j : i) {
|
||||
is >> j;
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
ll n, m, l;
|
||||
cin >> n >> m >> l;
|
||||
|
||||
V<pair<ll, ll>> hurd(n);
|
||||
for (auto &[l, r] : hurd) {
|
||||
cin >> l >> r;
|
||||
}
|
||||
|
||||
V<pair<ll, ll>> p(m);
|
||||
for (auto &[l, r] : p) {
|
||||
cin >> l >> r;
|
||||
}
|
||||
|
||||
int ans = 0;
|
||||
ll k = 1;
|
||||
|
||||
size_t i = 0;
|
||||
size_t j = 0;
|
||||
priority_queue<ll> pq;
|
||||
|
||||
while (i < hurd.size()) {
|
||||
while (j < p.size() && p[j].first <= hurd[i].first) {
|
||||
pq.push(p[j].second);
|
||||
j++;
|
||||
}
|
||||
|
||||
while (!pq.empty() && hurd[i].second - hurd[i].first + 1 >= k) {
|
||||
k += pq.top();
|
||||
pq.pop();
|
||||
ans++;
|
||||
}
|
||||
|
||||
if (hurd[i].second - hurd[i].first + 1 >= k) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i < hurd.size()) {
|
||||
cout << "-1\n";
|
||||
continue;
|
||||
}
|
||||
cout << ans << '\n';
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user