Changed the folder structure of codeforces problemsets
This commit is contained in:
32
codeforces/problemsets/chatroom/a.cpp
Normal file
32
codeforces/problemsets/chatroom/a.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
string s;
|
||||
cin >> s;
|
||||
|
||||
string hello = "olleh";
|
||||
|
||||
for(char& c : s){
|
||||
if(c == hello.back()){
|
||||
hello.pop_back();
|
||||
}
|
||||
if(hello.empty()){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(hello.empty()){
|
||||
cout << "YES";
|
||||
} else{
|
||||
cout << "NO";
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
39
codeforces/problemsets/football/football.cpp
Normal file
39
codeforces/problemsets/football/football.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
string s;
|
||||
getline(cin, s);
|
||||
int n = 0, m = 0;
|
||||
|
||||
bool no = true;
|
||||
|
||||
for(auto c : s){
|
||||
if(c == '0'){
|
||||
n++;
|
||||
m = 0;
|
||||
} else{
|
||||
m++;
|
||||
n = 0;
|
||||
}
|
||||
|
||||
if(abs(n - m) > 6){
|
||||
cout << "YES";
|
||||
no = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(no){
|
||||
cout << "NO";
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
28
codeforces/problemsets/hq9+/a.cpp
Normal file
28
codeforces/problemsets/hq9+/a.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
string s;
|
||||
getline(cin, s);
|
||||
bool no = true;
|
||||
for(char& c : s){
|
||||
if(c == 'H' || c == 'Q' || c == '9'){
|
||||
cout << "YES";
|
||||
no = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(no){
|
||||
cout << "NO";
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
55
codeforces/problemsets/interestingDrink/a.cpp
Normal file
55
codeforces/problemsets/interestingDrink/a.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int n, q, xi, mi;
|
||||
cin >> n;
|
||||
|
||||
vector<int> xs;
|
||||
xs.reserve(n);
|
||||
|
||||
for(int i = 0; i < n; ++i){
|
||||
cin >> xi;
|
||||
xs.push_back(xi);
|
||||
}
|
||||
sort(xs.begin(), xs.end());
|
||||
|
||||
cin >> q;
|
||||
for(int qi = 0; qi < q; ++qi){
|
||||
cin >> mi;
|
||||
|
||||
if(mi >= xs.back()){
|
||||
cout << n << "\n";
|
||||
continue;
|
||||
}
|
||||
if(mi < xs.front()){
|
||||
cout << "0\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
int start = 0, end = n - 1;
|
||||
int middle = (end + start) / 2;
|
||||
|
||||
while(middle != start && middle != end){
|
||||
if(mi > xs[middle]){
|
||||
start = middle + 1;
|
||||
} else{
|
||||
end = middle;
|
||||
}
|
||||
middle = (end + start) / 2;
|
||||
}
|
||||
if(mi < xs[middle]){
|
||||
cout << middle << "\n";
|
||||
} else{
|
||||
cout << middle + 1 << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
37
codeforces/problemsets/puzzlePieces/puzzlePieces.cpp
Normal file
37
codeforces/problemsets/puzzlePieces/puzzlePieces.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void test_case(int tc){
|
||||
int n, m;
|
||||
cin >> n >> m;
|
||||
|
||||
if(n < 2 || m < 2){
|
||||
cout << "YES\n";
|
||||
} else if(n == 2 && m == 2){
|
||||
cout << "YES\n";
|
||||
} else{
|
||||
cout << "NO\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
for(int tc = 1; tc <= t; ++tc){
|
||||
test_case(tc);
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
30
codeforces/problemsets/stringTask/a.cpp
Normal file
30
codeforces/problemsets/stringTask/a.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
string s, result = "";
|
||||
|
||||
getline(cin, s);
|
||||
for(char& c : s){
|
||||
if(c >= 'A' && c <= 'Z'){
|
||||
c += 32;
|
||||
}
|
||||
if(c == 'a' || c == 'e' || c == 'o' || c == 'i' || c == 'u' || c == 'y'){
|
||||
continue;
|
||||
} else{
|
||||
result += ".";
|
||||
result += c;
|
||||
}
|
||||
}
|
||||
|
||||
cout << result;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
47
codeforces/problemsets/taxi/a.cpp
Normal file
47
codeforces/problemsets/taxi/a.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int n, a, result = 0, ones = 0, twos = 0, threes = 0;
|
||||
cin >> n;
|
||||
|
||||
for(int i = 0; i < n; i++){
|
||||
cin >> a;
|
||||
if(a != 4){
|
||||
if(a == 1){
|
||||
ones++;
|
||||
} else if(a == 2){
|
||||
twos++;
|
||||
} else{
|
||||
threes++;
|
||||
}
|
||||
} else{
|
||||
result++;
|
||||
}
|
||||
}
|
||||
|
||||
int onethreegroups = min(ones, threes);
|
||||
result += threes;
|
||||
ones -= onethreegroups;
|
||||
|
||||
int doubletwos = twos / 2;
|
||||
result += doubletwos;
|
||||
twos -= doubletwos * 2;
|
||||
|
||||
if(twos == 1){
|
||||
result++;
|
||||
ones -= min(2, ones);
|
||||
}
|
||||
|
||||
result += ceil((float)ones / 4);
|
||||
|
||||
cout << result;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
32
codeforces/problemsets/team/team.cpp
Normal file
32
codeforces/problemsets/team/team.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
int n = 0;
|
||||
|
||||
for(int tc = 1; tc <= t; ++tc){
|
||||
int a, b, c;
|
||||
cin >> a >> b >> c;
|
||||
|
||||
if(a + b + c > 1){
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
cout << n;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
codeforces/problemsets/theatreSquare/a.cpp
Normal file
21
codeforces/problemsets/theatreSquare/a.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
long long n, m, a;
|
||||
|
||||
cin >> n >> m >> a;
|
||||
|
||||
long long result = ceil((double)n / (double)a) * ceil((double)m / (double)a);
|
||||
|
||||
cout << result;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
39
codeforces/problemsets/twins/twins.cpp
Normal file
39
codeforces/problemsets/twins/twins.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t, c, sum=0;
|
||||
cin >> t;
|
||||
|
||||
vector<int> coins;
|
||||
|
||||
for(int n = 0; n < t; n++){
|
||||
cin >> c;
|
||||
sum += c;
|
||||
coins.push_back(c);
|
||||
}
|
||||
|
||||
sort(coins.begin(), coins.end());
|
||||
reverse(coins.begin(), coins.end());
|
||||
|
||||
float half = (float)sum / 2;
|
||||
int acc = 0, result = 0;
|
||||
for(int& i : coins){
|
||||
acc += i;
|
||||
result++;
|
||||
if(acc > half){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cout << result;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
24
codeforces/problemsets/watermelon/watermelon.cpp
Normal file
24
codeforces/problemsets/watermelon/watermelon.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
if(n > 2 && n % 2 == 0){
|
||||
cout << "YES";
|
||||
} else{
|
||||
cout << "NO";
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
35
codeforces/problemsets/wayTooLongWords/wayTooLongWords.cpp
Normal file
35
codeforces/problemsets/wayTooLongWords/wayTooLongWords.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void test_case(int tc){
|
||||
string s;
|
||||
cin >> s;
|
||||
|
||||
if(s.length() > 10){
|
||||
cout << s.front() << s.length() - 2 << s.back() << '\n';
|
||||
} else{
|
||||
cout << s << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
for(int tc = 1; tc <= t; ++tc){
|
||||
test_case(tc);
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
29
codeforces/problemsets/youngPhysicist/a.cpp
Normal file
29
codeforces/problemsets/youngPhysicist/a.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int n, a, b, c, x = 0, y = 0, z = 0;
|
||||
cin >> n;
|
||||
|
||||
for(int i = 0; i < n; ++i){
|
||||
cin >> a >> b >> c;
|
||||
x += a;
|
||||
y += b;
|
||||
z += c;
|
||||
}
|
||||
|
||||
if(x == 0 && y == 0 && z == 0){
|
||||
cout << "YES";
|
||||
} else{
|
||||
cout << "NO";
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user