Precreation contest files
This commit is contained in:
18
Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/input1
Normal file
18
Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/input1
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
2
|
||||||
|
2
|
||||||
|
5
|
||||||
|
-> 4 3
|
||||||
|
<- 15
|
||||||
|
<- 4
|
||||||
|
-> 3 1
|
||||||
|
-> 1 3
|
||||||
|
1
|
||||||
|
8
|
||||||
|
-> 1 1
|
||||||
|
-> 1 2
|
||||||
|
-> 2 1
|
||||||
|
-> 2 2
|
||||||
|
<- 1
|
||||||
|
<- 2
|
||||||
|
<- 3
|
||||||
|
<- 4
|
||||||
13
Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/output1
Normal file
13
Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/output1
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
7
|
||||||
|
2 3
|
||||||
|
1 2
|
||||||
|
9
|
||||||
|
13
|
||||||
|
1
|
||||||
|
4
|
||||||
|
3
|
||||||
|
2
|
||||||
|
1 1
|
||||||
|
2 2
|
||||||
|
2 1
|
||||||
|
1 2
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int q;
|
||||||
|
cin >> q;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--)
|
||||||
|
solve();
|
||||||
|
}
|
||||||
BIN
Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/cpp.out
Executable file
BIN
Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/cpp.out
Executable file
Binary file not shown.
@@ -0,0 +1,6 @@
|
|||||||
|
5
|
||||||
|
2
|
||||||
|
4
|
||||||
|
5
|
||||||
|
7
|
||||||
|
100
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Alice
|
||||||
|
Bob
|
||||||
|
Alice
|
||||||
|
Alice
|
||||||
|
Bob
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--) {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
if (!(n & ((1 << 2) - 1)))
|
||||||
|
cout << "Bob\n";
|
||||||
|
else
|
||||||
|
cout << "Alice\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Codeforces/CodeforcesRound1034(Div3)/BTournament/cpp.out
Executable file
BIN
Codeforces/CodeforcesRound1034(Div3)/BTournament/cpp.out
Executable file
Binary file not shown.
7
Codeforces/CodeforcesRound1034(Div3)/BTournament/input1
Normal file
7
Codeforces/CodeforcesRound1034(Div3)/BTournament/input1
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
3
|
||||||
|
5 2 3
|
||||||
|
3 2 4 4 1
|
||||||
|
5 4 1
|
||||||
|
5 3 4 5 2
|
||||||
|
6 1 1
|
||||||
|
1 2 3 4 5 6
|
||||||
3
Codeforces/CodeforcesRound1034(Div3)/BTournament/output1
Normal file
3
Codeforces/CodeforcesRound1034(Div3)/BTournament/output1
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
YES
|
||||||
|
YES
|
||||||
|
NO
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int n, j, k;
|
||||||
|
cin >> n >> j >> k;
|
||||||
|
vector<int> a(n);
|
||||||
|
for (auto &i : a)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
if (a[j - 1] == *max_element(a.begin(), a.end())) {
|
||||||
|
cout << "YES\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k >= 2)
|
||||||
|
cout << "YES\n";
|
||||||
|
else
|
||||||
|
cout << "NO\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--)
|
||||||
|
solve();
|
||||||
|
}
|
||||||
BIN
Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/cpp.out
Executable file
BIN
Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/cpp.out
Executable file
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
3
|
||||||
|
6
|
||||||
|
1 3 5 4 7 2
|
||||||
|
4
|
||||||
|
13 10 12 20
|
||||||
|
7
|
||||||
|
1 2 3 4 5 6 7
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
100011
|
||||||
|
1101
|
||||||
|
1000001
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void min_maxer(vector<int> &_a, vector<int> &pre, vector<int> &stu,
|
||||||
|
vector<bool> &map) {
|
||||||
|
int n = _a.size();
|
||||||
|
map[0] = true;
|
||||||
|
map[n - 1] = true;
|
||||||
|
|
||||||
|
for (int i = 1; i < n; i++) {
|
||||||
|
if (_a[i] < _a[i - 1])
|
||||||
|
map[i] = true;
|
||||||
|
if (_a[n - i - 1] < _a[n - i - 2])
|
||||||
|
map[i] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
vector<int> a(n);
|
||||||
|
for (auto &i : a)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
vector<int> min_prefix(n), max_stufix(n);
|
||||||
|
vector<bool> map(n);
|
||||||
|
min_maxer(a, min_prefix, max_stufix, map);
|
||||||
|
for (auto i : map)
|
||||||
|
cout << i;
|
||||||
|
cout << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--)
|
||||||
|
solve();
|
||||||
|
}
|
||||||
11
Codeforces/CodeforcesRound1034(Div3)/EMEXCount/input1
Normal file
11
Codeforces/CodeforcesRound1034(Div3)/EMEXCount/input1
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
5
|
||||||
|
5
|
||||||
|
1 0 0 1 2
|
||||||
|
6
|
||||||
|
3 2 0 4 5 1
|
||||||
|
6
|
||||||
|
1 2 0 1 3 2
|
||||||
|
4
|
||||||
|
0 3 4 1
|
||||||
|
5
|
||||||
|
0 0 0 0 0
|
||||||
5
Codeforces/CodeforcesRound1034(Div3)/EMEXCount/output1
Normal file
5
Codeforces/CodeforcesRound1034(Div3)/EMEXCount/output1
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
1 2 4 3 2 1
|
||||||
|
1 6 5 4 3 2 1
|
||||||
|
1 3 5 4 3 2 1
|
||||||
|
1 3 3 2 1
|
||||||
|
1 1 1 1 1 1
|
||||||
31
Codeforces/CodeforcesRound1034(Div3)/EMEXCount/solution.cpp
Normal file
31
Codeforces/CodeforcesRound1034(Div3)/EMEXCount/solution.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "iostream"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int n, x;
|
||||||
|
cin >> n;
|
||||||
|
map<int, int> hash_map;
|
||||||
|
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
cin >> x;
|
||||||
|
if (hash_map.count(x) == 0)
|
||||||
|
hash_map[x] = 1;
|
||||||
|
else
|
||||||
|
hash_map[x]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k = 0; k <= n; k++) {
|
||||||
|
int cur_mex = 0;
|
||||||
|
for (auto &i : hash_map) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--)
|
||||||
|
solve();
|
||||||
|
}
|
||||||
BIN
Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/cpp.out
Executable file
BIN
Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/cpp.out
Executable file
Binary file not shown.
8
Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/input1
Normal file
8
Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/input1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
7
|
||||||
|
1 4 1 2
|
||||||
|
1 5 2 1
|
||||||
|
3 2 2 1
|
||||||
|
1 3 2 1
|
||||||
|
2 1 1 2
|
||||||
|
3 1 1 2
|
||||||
|
1 100 10000000 10000000
|
||||||
7
Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/output1
Normal file
7
Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/output1
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
3
|
||||||
|
6
|
||||||
|
1
|
||||||
|
3
|
||||||
|
-1
|
||||||
|
-1
|
||||||
|
990000000
|
||||||
43
Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/solution.cpp
Normal file
43
Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/solution.cpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int a, b, x, y;
|
||||||
|
cin >> a >> b >> x >> y;
|
||||||
|
|
||||||
|
if (a > b) {
|
||||||
|
if (a - b == 1) {
|
||||||
|
if (a % 2 != 0) {
|
||||||
|
cout << y << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << "-1\n";
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int diff = b - a;
|
||||||
|
int xdiff = diff * x;
|
||||||
|
if (diff % 2 == 0) {
|
||||||
|
cout << min(xdiff, ((diff * x) / 2) + ((diff * y) / 2)) << endl;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (a % 2 != 0) {
|
||||||
|
|
||||||
|
cout << min(xdiff, (diff / 2 + 1) * x + (diff / 2) * y) << endl;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
cout << min(xdiff, (diff / 2) * x + (diff / 2 + 1) * y) << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--)
|
||||||
|
solve();
|
||||||
|
}
|
||||||
BIN
Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/cpp.out
Executable file
BIN
Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/cpp.out
Executable file
Binary file not shown.
@@ -0,0 +1,6 @@
|
|||||||
|
5
|
||||||
|
6
|
||||||
|
96
|
||||||
|
78
|
||||||
|
122
|
||||||
|
696
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
6
|
||||||
|
6
|
||||||
|
7
|
||||||
|
1
|
||||||
|
6
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--) {
|
||||||
|
int x;
|
||||||
|
cin >> x;
|
||||||
|
string xstr = to_string(x);
|
||||||
|
|
||||||
|
int res = 10;
|
||||||
|
for (const char &i : xstr) {
|
||||||
|
res = min(res, (int)(i - '0'));
|
||||||
|
}
|
||||||
|
cout << res << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/cpp.out
Executable file
BIN
Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/cpp.out
Executable file
Binary file not shown.
@@ -0,0 +1,11 @@
|
|||||||
|
5
|
||||||
|
5 1
|
||||||
|
0 1 0 0 0
|
||||||
|
7 3
|
||||||
|
0 0 0 0 0 0 0
|
||||||
|
3 1
|
||||||
|
1 1 1
|
||||||
|
4 2
|
||||||
|
0 1 0 1
|
||||||
|
6 2
|
||||||
|
0 0 1 0 0 0
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
3
|
||||||
|
2
|
||||||
|
0
|
||||||
|
0
|
||||||
|
2
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int n, k;
|
||||||
|
cin >> n >> k;
|
||||||
|
vector<int> a(n);
|
||||||
|
for (int &i : a)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
int len = 0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (len == k) {
|
||||||
|
len = 0;
|
||||||
|
res++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (a[i] == 0) {
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
if (a[i] == 1) {
|
||||||
|
len = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (len == k)
|
||||||
|
res++;
|
||||||
|
cout << res << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--)
|
||||||
|
solve();
|
||||||
|
}
|
||||||
BIN
Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/cpp.out
Executable file
BIN
Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/cpp.out
Executable file
Binary file not shown.
@@ -0,0 +1,11 @@
|
|||||||
|
5
|
||||||
|
5 3
|
||||||
|
3 2 1 4 5
|
||||||
|
3 1
|
||||||
|
1 3 4
|
||||||
|
4 4
|
||||||
|
4 4 4 2
|
||||||
|
6 2
|
||||||
|
2 3 6 9 1 2
|
||||||
|
4 2
|
||||||
|
1 2 5 6
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
YES
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
YES
|
||||||
|
NO
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int n, k;
|
||||||
|
cin >> n >> k;
|
||||||
|
vector<int> a(n);
|
||||||
|
for (auto &i : a)
|
||||||
|
cin >> i;
|
||||||
|
int h = a[k - 1];
|
||||||
|
sort(a.begin(), a.end());
|
||||||
|
|
||||||
|
int time = 0;
|
||||||
|
for (auto H : a) {
|
||||||
|
if (H <= h)
|
||||||
|
continue;
|
||||||
|
time += H - h;
|
||||||
|
if (time > h) {
|
||||||
|
cout << "NO\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
h = H;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "YES\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/cpp.out
Executable file
BIN
Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/cpp.out
Executable file
Binary file not shown.
16
Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/input1
Normal file
16
Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/input1
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
5
|
||||||
|
6
|
||||||
|
72 24 3 3 3 3
|
||||||
|
3 3 3 6 12 144
|
||||||
|
3
|
||||||
|
1 2 3
|
||||||
|
4 5 6
|
||||||
|
5
|
||||||
|
125 125 125 25 25
|
||||||
|
25 25 25 25 75
|
||||||
|
4
|
||||||
|
123 421 282 251
|
||||||
|
125 1981 239 223
|
||||||
|
3
|
||||||
|
124 521 125
|
||||||
|
125 121 121
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
YES
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
NO
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
vector<int> pre(n), stu(n);
|
||||||
|
for (int &i : pre)
|
||||||
|
cin >> i;
|
||||||
|
for (int &i : stu)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
if (pre[n - 1] != stu[0]) {
|
||||||
|
cout << "NO\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < n - 1; i++) {
|
||||||
|
if (pre[i] < pre[i + 1]) {
|
||||||
|
cout << "NO\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pre[i] % pre[i + 1] != 0) {
|
||||||
|
cout << "NO\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = n - 1; i > 0; i--) {
|
||||||
|
if (stu[i] < stu[i - 1]) {
|
||||||
|
cout << "NO\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stu[i] % stu[i - 1] != 0) {
|
||||||
|
cout << "NO\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << "YES\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--)
|
||||||
|
solve();
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
3
|
||||||
|
3
|
||||||
|
2 2 3
|
||||||
|
5
|
||||||
|
4 5 5 2 4
|
||||||
|
1
|
||||||
|
1
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
NO
|
||||||
|
YES
|
||||||
|
4
|
||||||
|
4 5 2 4
|
||||||
|
NO
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
vector<int> a(n);
|
||||||
|
for (int &i : a)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
for (int i = 0; i < n - 1; i++) {
|
||||||
|
if (a[i] > a[i + 1]) {
|
||||||
|
cout << "YES\n2\n";
|
||||||
|
cout << a[i] << " " << a[i + 1] << "\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << "NO\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--)
|
||||||
|
solve();
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
3
|
||||||
|
2
|
||||||
|
1 2
|
||||||
|
3
|
||||||
|
1 2 3
|
||||||
|
4
|
||||||
|
3 0 2 3
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
2
|
||||||
|
2
|
||||||
|
3
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
vector<int> a(n);
|
||||||
|
for (auto &i : a)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
cout << min(a[0] + a[1], 2 * a[0]) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--)
|
||||||
|
solve();
|
||||||
|
}
|
||||||
BIN
Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/cpp.out
Executable file
BIN
Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/cpp.out
Executable file
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
2
|
||||||
|
1
|
||||||
|
3
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
2
|
||||||
|
6
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
while (t--) {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
cout << 2 * n << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/cpp.out
Executable file
BIN
Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/cpp.out
Executable file
Binary file not shown.
11
Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/input1
Normal file
11
Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/input1
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
5
|
||||||
|
4
|
||||||
|
2 3 5 7
|
||||||
|
4
|
||||||
|
115 9 2 28
|
||||||
|
5
|
||||||
|
8 4 1 6 2
|
||||||
|
6
|
||||||
|
1 5 4 1 4 7
|
||||||
|
2
|
||||||
|
100000 100000
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
YES
|
||||||
|
NO
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
YES
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int a[200];
|
||||||
|
|
||||||
|
bool check(int a, int b, int c) {
|
||||||
|
if (a + b <= c)
|
||||||
|
return false;
|
||||||
|
if (a + c <= b)
|
||||||
|
return false;
|
||||||
|
if (b + c <= a)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void run() {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
cin >> a[i];
|
||||||
|
|
||||||
|
if (n == 2) {
|
||||||
|
if (check(a[0], a[0], a[1]) || check(a[0], a[1], a[1])) {
|
||||||
|
cout << "YES\n";
|
||||||
|
} else {
|
||||||
|
cout << "NO\n";
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < n - 2; i++) {
|
||||||
|
if (check(a[i], a[i + 1], a[i + 2])) {
|
||||||
|
cout << "YES\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < n - 1; i++) {
|
||||||
|
if (check(a[i], a[i], a[i + 1]) || check(a[i], a[i + 1], a[i + 1])) {
|
||||||
|
cout << "YES\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "NO\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t--) {
|
||||||
|
run();
|
||||||
|
};
|
||||||
|
}
|
||||||
BIN
misc/bdhsg_1015/a.out
Executable file
BIN
misc/bdhsg_1015/a.out
Executable file
Binary file not shown.
21
misc/bdhsg_1015/max3.cpp
Normal file
21
misc/bdhsg_1015/max3.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
freopen("max3.inp", "r", stdin);
|
||||||
|
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
vector<int> a(n);
|
||||||
|
for (int &i : a)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
for (int i = 0; i < n - 2; i++)
|
||||||
|
res = max(res, a[i] + a[i + 1] + a[i + 2]);
|
||||||
|
|
||||||
|
cout << res << '\n';
|
||||||
|
}
|
||||||
2
misc/bdhsg_1015/max3.inp
Normal file
2
misc/bdhsg_1015/max3.inp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
6
|
||||||
|
1 3 4 2 7 9
|
||||||
32
misc/bdhsg_1015/search.cpp
Normal file
32
misc/bdhsg_1015/search.cpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
freopen("search.inp", "r", stdin);
|
||||||
|
|
||||||
|
int n, x;
|
||||||
|
cin >> n >> x;
|
||||||
|
vector<int> a(n);
|
||||||
|
for (int &i : a)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
if (x - 1 > n || x < 0) {
|
||||||
|
cout << -1 << '\n';
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
x = a[x - 1];
|
||||||
|
}
|
||||||
|
int cnt = 0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
// cout << a[i] << '\n';
|
||||||
|
if (a[i] == x) {
|
||||||
|
cout << i + 1 << ' ';
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << '\n';
|
||||||
|
cout << ((cnt == 0) ? -1 : cnt) << '\n';
|
||||||
|
}
|
||||||
2
misc/bdhsg_1015/search.inp
Normal file
2
misc/bdhsg_1015/search.inp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
6 2
|
||||||
|
1 3 3 5 7 3
|
||||||
0
misc/bdhsg_1015/search2.cpp
Normal file
0
misc/bdhsg_1015/search2.cpp
Normal file
0
misc/bdhsg_1015/search2.inp
Normal file
0
misc/bdhsg_1015/search2.inp
Normal file
BIN
misc/binary-search/cpp.out
Executable file
BIN
misc/binary-search/cpp.out
Executable file
Binary file not shown.
35
misc/binary-search/ghepcap.cpp
Normal file
35
misc/binary-search/ghepcap.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int a[100000];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
freopen("ghepcap.inp", "r", stdin);
|
||||||
|
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
cin >> a[i];
|
||||||
|
sort(a, a + n);
|
||||||
|
// 89 90 91 99 100 101
|
||||||
|
int res = 0;
|
||||||
|
for (int j = 0; j < n; j++) {
|
||||||
|
int l = 0, r = j;
|
||||||
|
// int ans = a[n - 1];
|
||||||
|
while (l < r) {
|
||||||
|
int mid = (l + r) / 2;
|
||||||
|
if (10 * a[mid] < a[j] * 9) {
|
||||||
|
l = mid + 1;
|
||||||
|
} else {
|
||||||
|
r = mid;
|
||||||
|
// ans = min(ans, mid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// res += j - ans;
|
||||||
|
res += j - l;
|
||||||
|
}
|
||||||
|
cout << res << '\n';
|
||||||
|
}
|
||||||
4
misc/binary-search/ghepcap.inp
Normal file
4
misc/binary-search/ghepcap.inp
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
6
|
||||||
|
100 89 90 101 91 99
|
||||||
|
|
||||||
|
|
||||||
40
misc/binary-search/p145sumg.cpp
Normal file
40
misc/binary-search/p145sumg.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
#include <ios>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int a[100000];
|
||||||
|
int n, m;
|
||||||
|
|
||||||
|
int checker(int k) {
|
||||||
|
int ret = 0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
ret += k / a[i];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
freopen("p145sumg.inp", "r", stdin);
|
||||||
|
|
||||||
|
cin >> n >> m;
|
||||||
|
int l = 1, r;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
cin >> a[i];
|
||||||
|
r = max(r, a[i]);
|
||||||
|
}
|
||||||
|
r *= m;
|
||||||
|
|
||||||
|
int res = r;
|
||||||
|
while (l < r) {
|
||||||
|
int mid = (l + r) / 2;
|
||||||
|
if (checker(mid) >= m) {
|
||||||
|
r = mid;
|
||||||
|
res = min(mid, res);
|
||||||
|
} else {
|
||||||
|
l = mid + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << res << "\n";
|
||||||
|
}
|
||||||
8
misc/binary-search/p145sumg.inp
Normal file
8
misc/binary-search/p145sumg.inp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
7 10
|
||||||
|
3
|
||||||
|
8
|
||||||
|
3
|
||||||
|
6
|
||||||
|
9
|
||||||
|
2
|
||||||
|
4
|
||||||
42
misc/binary-search/ptit126j.cpp
Normal file
42
misc/binary-search/ptit126j.cpp
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
int a[1000000];
|
||||||
|
int n, m;
|
||||||
|
|
||||||
|
int check(int k) {
|
||||||
|
int res = 0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (a[i] - k > 0)
|
||||||
|
res += a[i] - k;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
|
||||||
|
freopen("ptit126j.inp", "r", stdin);
|
||||||
|
|
||||||
|
cin >> n >> m;
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
cin >> a[i];
|
||||||
|
sort(a, a + n);
|
||||||
|
|
||||||
|
// 10 15 17 20
|
||||||
|
int l = 0, r = a[n - 1];
|
||||||
|
int res = a[n - 1];
|
||||||
|
while (l < r) {
|
||||||
|
int mid = (l + r) / 2;
|
||||||
|
|
||||||
|
if (check(mid) >= m) {
|
||||||
|
// cout << mid << "\n";
|
||||||
|
res = mid;
|
||||||
|
l = mid + 1;
|
||||||
|
} else {
|
||||||
|
r = mid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << res << '\n';
|
||||||
|
}
|
||||||
2
misc/binary-search/ptit126j.inp
Normal file
2
misc/binary-search/ptit126j.inp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
5 20
|
||||||
|
4 42 40 26 46
|
||||||
40
misc/binary-search/toy.cpp
Normal file
40
misc/binary-search/toy.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int n, m;
|
||||||
|
|
||||||
|
int checker(const vector<int> &_a, int k) {
|
||||||
|
int _n = n;
|
||||||
|
for (auto i : _a) {
|
||||||
|
while (i > k) {
|
||||||
|
i -= k;
|
||||||
|
_n -= k;
|
||||||
|
}
|
||||||
|
if (i > 0) {
|
||||||
|
_n - k
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
freopen("toy.inp", "r", stdin);
|
||||||
|
|
||||||
|
cin >> n >> m;
|
||||||
|
vector<int> a(n);
|
||||||
|
for (auto &i : a)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
int l = 0, r = n;
|
||||||
|
while (l < r) {
|
||||||
|
int mid = (l + r) / 2;
|
||||||
|
|
||||||
|
if (checker(a, mid)) {
|
||||||
|
r = mid;
|
||||||
|
} else {
|
||||||
|
l = mid + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
misc/binary-search/toy.inp
Normal file
3
misc/binary-search/toy.inp
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
5 2
|
||||||
|
4
|
||||||
|
7
|
||||||
6
misc/chuyen-de-xau/B3.INP
Normal file
6
misc/chuyen-de-xau/B3.INP
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
5
|
||||||
|
ABCD
|
||||||
|
EFGHIJK
|
||||||
|
TINHOCTRE
|
||||||
|
ABCD
|
||||||
|
EFGHIJK
|
||||||
4
misc/chuyen-de-xau/B4.INP
Normal file
4
misc/chuyen-de-xau/B4.INP
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
3
|
||||||
|
34
|
||||||
|
3
|
||||||
|
30
|
||||||
3
misc/chuyen-de-xau/B6.INP
Normal file
3
misc/chuyen-de-xau/B6.INP
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
3 11
|
||||||
|
3 4 2
|
||||||
|
123 0 45
|
||||||
BIN
misc/chuyen-de-xau/a.out
Executable file
BIN
misc/chuyen-de-xau/a.out
Executable file
Binary file not shown.
45
misc/chuyen-de-xau/b2.cpp
Normal file
45
misc/chuyen-de-xau/b2.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int segn[300];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
|
||||||
|
for (int j = 0; j < 300; j++)
|
||||||
|
segn[j] = 0;
|
||||||
|
string S;
|
||||||
|
cin >> S;
|
||||||
|
const int n = S.length();
|
||||||
|
int res1 = 0;
|
||||||
|
int res2 = 0;
|
||||||
|
|
||||||
|
int l = 0, r = 1;
|
||||||
|
int i = 0;
|
||||||
|
while (r < n) {
|
||||||
|
if (S[l] == S[r])
|
||||||
|
r++;
|
||||||
|
else {
|
||||||
|
segn[i] = r - l;
|
||||||
|
l = r;
|
||||||
|
r++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
segn[i] = r - l;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
for (int k = 0; k < i; k++) {
|
||||||
|
res1 = max(res1, segn[k]);
|
||||||
|
if (segn[k + 1] == 1) {
|
||||||
|
res2 = max(res2, segn[k] + segn[k + 1] + segn[k + 2]);
|
||||||
|
}
|
||||||
|
if (k != 0 || k != n - 1) {
|
||||||
|
res2 = max(res2, segn[k] + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << res1 << '\n';
|
||||||
|
cout << res2 << '\n';
|
||||||
|
}
|
||||||
28
misc/chuyen-de-xau/b3.cpp
Normal file
28
misc/chuyen-de-xau/b3.cpp
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
freopen("B3.INP", "r", stdin);
|
||||||
|
|
||||||
|
map<string, char> hash;
|
||||||
|
|
||||||
|
int q;
|
||||||
|
cin >> q;
|
||||||
|
for (int i = 0; i < q; i++) {
|
||||||
|
string a;
|
||||||
|
cin >> a;
|
||||||
|
// cout << a;
|
||||||
|
if (hash.find(a) == hash.end()) {
|
||||||
|
hash[a] = 1;
|
||||||
|
} else {
|
||||||
|
hash[a] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto i : hash) {
|
||||||
|
if (i.second == 1)
|
||||||
|
cout << i.first << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
31
misc/chuyen-de-xau/b4.cpp
Normal file
31
misc/chuyen-de-xau/b4.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
string S[100];
|
||||||
|
|
||||||
|
bool check(const string &a, const string &b) {
|
||||||
|
const string ab = a + b, ba = b + a;
|
||||||
|
if (stoi(ab) < stoi(ba))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
freopen("B4.INP", "r", stdin);
|
||||||
|
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
string a;
|
||||||
|
cin >> a;
|
||||||
|
S[i] = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
sort(S, S + n, check);
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
cout << S[i];
|
||||||
|
}
|
||||||
|
cout << '\n';
|
||||||
|
}
|
||||||
38
misc/chuyen-de-xau/b5.cpp
Normal file
38
misc/chuyen-de-xau/b5.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
string s;
|
||||||
|
cin >> s;
|
||||||
|
|
||||||
|
vector<char> digits;
|
||||||
|
for (char c : s) {
|
||||||
|
if (isdigit(c))
|
||||||
|
digits.push_back(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int m = digits.size();
|
||||||
|
string result = "";
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
for (int need = 5; need > 0; need--) {
|
||||||
|
char best = '0';
|
||||||
|
int bestPos = pos;
|
||||||
|
|
||||||
|
for (int i = pos; i <= m - need; i++) {
|
||||||
|
if (digits[i] > best) {
|
||||||
|
best = digits[i];
|
||||||
|
bestPos = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.push_back(best);
|
||||||
|
pos = bestPos + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << result;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
23
misc/chuyen-de-xau/b6.cpp
Normal file
23
misc/chuyen-de-xau/b6.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
|
||||||
|
int p, k;
|
||||||
|
cin >> p >> k;
|
||||||
|
vector<int> a(p), s(p);
|
||||||
|
for (int &i : a)
|
||||||
|
cin >> i;
|
||||||
|
for (int &i : s)
|
||||||
|
cin >> i;
|
||||||
|
|
||||||
|
deque<int> stack;
|
||||||
|
|
||||||
|
for (int i = 0; i < p; i++) {
|
||||||
|
while (a[i]--) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
misc/chuyen-de-xau/b7.cpp
Normal file
30
misc/chuyen-de-xau/b7.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
int counter[(int)('z' - 'a')];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(NULL);
|
||||||
|
|
||||||
|
string a;
|
||||||
|
cin >> a;
|
||||||
|
for (const auto i : a) {
|
||||||
|
counter[i - 'a']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sum = 0;
|
||||||
|
for (const auto i : counter) {
|
||||||
|
sum += i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int max_x = 0;
|
||||||
|
char max_c;
|
||||||
|
for (int i = 0; i < 'z' - 'a'; i++) {
|
||||||
|
if (counter[i] > max_x) {
|
||||||
|
max_x = counter[i];
|
||||||
|
max_c = 'a' + i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << sum << ' ' << max_c << '\n';
|
||||||
|
}
|
||||||
22
misc/chuyen-de-xau/b8.cpp
Normal file
22
misc/chuyen-de-xau/b8.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
string words[20];
|
||||||
|
|
||||||
|
bool checker(const string &a, const string &b) { return a.size() < b.size(); }
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
freopen("b8.inp", "r", stdin);
|
||||||
|
|
||||||
|
int n = 0;
|
||||||
|
while (cin >> words[n] && n < 20)
|
||||||
|
n++;
|
||||||
|
|
||||||
|
stable_sort(words, words + n, checker);
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
cout << words[i] << " ";
|
||||||
|
}
|
||||||
|
cout << '\n';
|
||||||
|
}
|
||||||
1
misc/chuyen-de-xau/b8.inp
Normal file
1
misc/chuyen-de-xau/b8.inp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
acb abcde abcd abc
|
||||||
22
misc/hsg-hn-2025/.vscode/launch.json
vendored
Normal file
22
misc/hsg-hn-2025/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug C++ (input.inp)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
|
||||||
|
"args": ["<", "${fileBasenameNoExtension}.inp"],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"preLaunchTask": "Build C++",
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"externalConsole": false,
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty printing",
|
||||||
|
"text": "-enable-pretty-printing"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
22
misc/hsg-hn-2025/.vscode/tasks.json
vendored
Normal file
22
misc/hsg-hn-2025/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Build C++",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "g++",
|
||||||
|
"args": [
|
||||||
|
"-std=gnu++17",
|
||||||
|
"-O2",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileBasenameNoExtension}"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
misc/hsg-hn-2025/a.out
Executable file
BIN
misc/hsg-hn-2025/a.out
Executable file
Binary file not shown.
BIN
misc/hsg-hn-2025/denlong
Executable file
BIN
misc/hsg-hn-2025/denlong
Executable file
Binary file not shown.
17
misc/hsg-hn-2025/denlong.cpp
Normal file
17
misc/hsg-hn-2025/denlong.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int n, k, x;
|
||||||
|
cin >> n >> k >> x;
|
||||||
|
vector<vector<int>> hash(9, vector<int>(n, 0));
|
||||||
|
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
int a;
|
||||||
|
cin >> a;
|
||||||
|
if (i == 0)
|
||||||
|
hash[a][i] = 1;
|
||||||
|
else
|
||||||
|
hash[a][i] = hash[a][i - 1] + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
misc/hsg-hn-2025/denlong.inp
Normal file
2
misc/hsg-hn-2025/denlong.inp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
6 2 2
|
||||||
|
1 9 3 2 3 5
|
||||||
0
misc/hsg-hn-2025/denlong.out
Normal file
0
misc/hsg-hn-2025/denlong.out
Normal file
35
misc/hsg-hn-2025/muasam.cpp
Normal file
35
misc/hsg-hn-2025/muasam.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
const int MAX_N = 1e6;
|
||||||
|
int a[MAX_N];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
freopen("muasam.inp", "r", stdin);
|
||||||
|
freopen("muasam.out", "w", stdout);
|
||||||
|
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
int n, l, r;
|
||||||
|
cin >> n >> l >> r;
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
cin >> a[i];
|
||||||
|
int res = 1e9;
|
||||||
|
|
||||||
|
sort(a, a + n);
|
||||||
|
int L = 0, R = n - 1;
|
||||||
|
while (L < R) {
|
||||||
|
int sum = a[L] + a[R];
|
||||||
|
if (sum > r)
|
||||||
|
R--;
|
||||||
|
else if (sum < l)
|
||||||
|
L++;
|
||||||
|
else {
|
||||||
|
res = min(res, sum);
|
||||||
|
R--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << res << '\n';
|
||||||
|
}
|
||||||
22
misc/hsg-hp-2025/.vscode/launch.json
vendored
Normal file
22
misc/hsg-hp-2025/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug C++ (input.inp)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
|
||||||
|
"args": ["<", "${fileBasenameNoExtension}.inp"],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"preLaunchTask": "Build C++",
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"externalConsole": false,
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty printing",
|
||||||
|
"text": "-enable-pretty-printing"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
22
misc/hsg-hp-2025/.vscode/tasks.json
vendored
Normal file
22
misc/hsg-hp-2025/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Build C++",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "g++",
|
||||||
|
"args": [
|
||||||
|
"-std=gnu++17",
|
||||||
|
"-O2",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileBasenameNoExtension}"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
misc/hsg-hp-2025/a.out
Executable file
BIN
misc/hsg-hp-2025/a.out
Executable file
Binary file not shown.
24
misc/hsg-hp-2025/cbai1.cpp
Normal file
24
misc/hsg-hp-2025/cbai1.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string a;
|
||||||
|
cin >> a;
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
string output = "";
|
||||||
|
|
||||||
|
for (int i = a.length() - 1; i >= 0; i--) {
|
||||||
|
if ('0' <= a[i] && a[i] <= '9')
|
||||||
|
res += (int)(a[i] - '0');
|
||||||
|
else
|
||||||
|
output += a[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << res << '\n';
|
||||||
|
if (output == "")
|
||||||
|
cout << -1 << '\n';
|
||||||
|
else
|
||||||
|
cout << output << '\n';
|
||||||
|
}
|
||||||
50
misc/hsg-hp-2025/cbai2.cpp
Normal file
50
misc/hsg-hp-2025/cbai2.cpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
const int max_n = 1e7;
|
||||||
|
|
||||||
|
char is_prime[max_n + 1];
|
||||||
|
void sieve() {
|
||||||
|
for (int i = 0; i <= max_n; i++)
|
||||||
|
is_prime[i] = 1;
|
||||||
|
is_prime[0] = 0;
|
||||||
|
is_prime[1] = 0;
|
||||||
|
|
||||||
|
// 2 check
|
||||||
|
for (int i = 4; i <= max_n; i += 2)
|
||||||
|
is_prime[i] = 0;
|
||||||
|
|
||||||
|
// other
|
||||||
|
for (int i = 3; i * i <= max_n; i += 2)
|
||||||
|
if (is_prime[i])
|
||||||
|
for (int j = i * i; j <= max_n; j += i)
|
||||||
|
is_prime[j] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int solve() {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
if (!is_prime[n])
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int digit_sum = 0;
|
||||||
|
while (n) {
|
||||||
|
digit_sum += n % 10;
|
||||||
|
n /= 10;
|
||||||
|
}
|
||||||
|
if (!is_prime[digit_sum])
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
sieve();
|
||||||
|
int q;
|
||||||
|
cin >> q;
|
||||||
|
int res = 0;
|
||||||
|
while (q--) {
|
||||||
|
res += solve();
|
||||||
|
}
|
||||||
|
cout << res << "\n";
|
||||||
|
}
|
||||||
2
misc/hsg-hp-2025/cbai2.inp
Normal file
2
misc/hsg-hp-2025/cbai2.inp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
6
|
||||||
|
2 3 19 23 29 17
|
||||||
28
misc/hsg-hp-2025/cbai3.cpp
Normal file
28
misc/hsg-hp-2025/cbai3.cpp
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
int a[1000000];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
int m, n, S;
|
||||||
|
cin >> m >> n >> S;
|
||||||
|
for (int i = 0; i < m * n; i++)
|
||||||
|
cin >> a[i];
|
||||||
|
|
||||||
|
sort(a, a + m * n);
|
||||||
|
|
||||||
|
int l = 0, r = m * n - 1;
|
||||||
|
int cur_max = -1;
|
||||||
|
while (l < r) {
|
||||||
|
if (a[l] + a[r] > S)
|
||||||
|
r--;
|
||||||
|
else {
|
||||||
|
cur_max = max(cur_max, a[l] + a[r]);
|
||||||
|
l++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << cur_max << '\n';
|
||||||
|
}
|
||||||
4
misc/hsg-hp-2025/cbai3.inp
Normal file
4
misc/hsg-hp-2025/cbai3.inp
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
3 4 10
|
||||||
|
6 7 8 9
|
||||||
|
5 6 7 8
|
||||||
|
9 8 8 7
|
||||||
BIN
misc/hsg-hp-2025/cbai4
Executable file
BIN
misc/hsg-hp-2025/cbai4
Executable file
Binary file not shown.
56
misc/hsg-hp-2025/cbai4.cpp
Normal file
56
misc/hsg-hp-2025/cbai4.cpp
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
vector<deque<int>> char_pos(26);
|
||||||
|
|
||||||
|
int n, q;
|
||||||
|
string S;
|
||||||
|
cin >> n >> q >> S;
|
||||||
|
|
||||||
|
vector<int> is_exist(n, 1);
|
||||||
|
set<int> exist_char;
|
||||||
|
|
||||||
|
// O(n)
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
char_pos[S[i] - 'A'].push_back(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// O(1)
|
||||||
|
for (int i = 0; i < 26; i++)
|
||||||
|
if (!char_pos[i].empty())
|
||||||
|
exist_char.insert(i);
|
||||||
|
|
||||||
|
while (q--) {
|
||||||
|
if (exist_char.empty())
|
||||||
|
break;
|
||||||
|
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
int target_char;
|
||||||
|
if (t == 0)
|
||||||
|
target_char = *exist_char.begin();
|
||||||
|
else
|
||||||
|
target_char = *exist_char.rbegin();
|
||||||
|
|
||||||
|
int target_idx = char_pos[target_char].front();
|
||||||
|
char_pos[target_char].pop_front();
|
||||||
|
is_exist[target_idx] = 0;
|
||||||
|
|
||||||
|
if (char_pos[target_char].empty())
|
||||||
|
exist_char.erase(target_char);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
if (is_exist[i])
|
||||||
|
cout << S[i];
|
||||||
|
cout << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
solve();
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user