diff --git a/Codeforces/pclists/list1/A.cpp b/Codeforces/pclists/list1/A.cpp new file mode 100644 index 0000000..f7a71e0 --- /dev/null +++ b/Codeforces/pclists/list1/A.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; + +int main(){ + + int n,g,f,c; cin >> n >> g >> f >> c; + int count = 0; + while(g and f) { + count++; + g--,f--; + } + + count+=c; + cout << (count>n?n:count) << endl; + + return 0; +} \ No newline at end of file diff --git a/Codeforces/pclists/list1/B.cpp b/Codeforces/pclists/list1/B.cpp new file mode 100644 index 0000000..87bcb22 --- /dev/null +++ b/Codeforces/pclists/list1/B.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; + +int main(){ + + int n; cin >> n; + vector values; + while(n--) { + int aux; cin >> aux; + values.emplace_back(aux); + } + + n = values.size(); + int count = 0, maxValue = *max_element(values.begin(),values.end()); + for(int i = 0; i < n; ++i) + count += abs(maxValue-values[i]); + + cout << count << endl; + + return 0; +} \ No newline at end of file diff --git a/Codeforces/pclists/list1/C.cpp b/Codeforces/pclists/list1/C.cpp new file mode 100644 index 0000000..e34115e --- /dev/null +++ b/Codeforces/pclists/list1/C.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; + +int main(){ + + int n,a; cin >> n >> a; + while(500 < n) { + n-=500; + } + + cout << ((n-a)<=0?"Sim":"Nao") << endl; + + return 0; +} \ No newline at end of file diff --git a/Codeforces/pclists/list1/D.cpp b/Codeforces/pclists/list1/D.cpp new file mode 100644 index 0000000..0d10c49 --- /dev/null +++ b/Codeforces/pclists/list1/D.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; + +int main(){ + + int n; cin >> n; + vector names; + while(n--) { + string aux; cin >> aux; + names.emplace_back(aux); + } + + vector names_sorted = names; + sort(names_sorted.begin(),names_sorted.end()); + for(int i = 0; i < (int)names.size();++i) { + auto it = find(names_sorted.begin(),names_sorted.end(), names[i]); + cout << it - names_sorted.begin() << " "; + + } + cout << endl; + + return 0; +} \ No newline at end of file diff --git a/Codeforces/pclists/list1/E.cpp b/Codeforces/pclists/list1/E.cpp new file mode 100644 index 0000000..24b5c2f --- /dev/null +++ b/Codeforces/pclists/list1/E.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; + +int main(){ + + int n; cin >> n; + vector contests; + while(n--) { + int aux; cin >> aux; + contests.emplace_back(aux); + } + + int count = 0; + sort(contests.begin(),contests.end()); + for(int i = 0; i < (int)contests.size(); ++i) { + auto it = find(contests.begin(),contests.end(), i+1); + if(it != contests.end()) + count++; + } + + cout << count << endl; + + return 0; + +} \ No newline at end of file diff --git a/Codeforces/pclists/list1/F.cpp b/Codeforces/pclists/list1/F.cpp new file mode 100644 index 0000000..884ef97 --- /dev/null +++ b/Codeforces/pclists/list1/F.cpp @@ -0,0 +1,28 @@ +#include +using namespace std; + +int count_digits(int n) { + int count = 0; + while(n) { + count += (n%10); + n /= 10; + } + + return count; +} + + +int main(){ + + int n, a, b; cin >> n >> a >> b; + vector nums(n); + int count = 0; + iota(nums.begin(),nums.end(),1); + + for(auto i : nums) + if(count_digits(i) >= a and count_digits(i) <= b) + count += i; + + cout << count << endl; + return 0; +} \ No newline at end of file diff --git a/Codeforces/pclists/list1/G.cpp b/Codeforces/pclists/list1/G.cpp new file mode 100644 index 0000000..4eb5a05 --- /dev/null +++ b/Codeforces/pclists/list1/G.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; + +bool dist_nums(int n) { + + set nums; + + while(n) { + int aux = n%10; + if(nums.count(aux)) + return false; + nums.insert(aux); + n /= 10; + } + + return true; + +} + +int main(){ + + int n; cin >> n; + n+=1; + while(not dist_nums(n)) + n++; + + cout << n << endl; + + return 0; +} \ No newline at end of file diff --git a/Codeforces/pclists/list1/H.cpp b/Codeforces/pclists/list1/H.cpp new file mode 100644 index 0000000..96e9bae --- /dev/null +++ b/Codeforces/pclists/list1/H.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + +int main(){ + + int n,x,y; cin >> n >> x >> y; + pair gast_dist = {INT_MAX,-1}; + for(int i = 0; i < n; ++i) { + int distx,disty,value; cin >> distx >> disty >> value; + if((abs(distx-x)+abs(disty-y))*2+(value) < gast_dist.first) + gast_dist = {(abs(distx-x)+abs(disty-y))*2+(value), i+1}; + } + + cout << gast_dist.first << " " << gast_dist.second << endl; + return 0; +} \ No newline at end of file diff --git a/Codeforces/pclists/list1/I.cpp b/Codeforces/pclists/list1/I.cpp new file mode 100644 index 0000000..f3f6d35 --- /dev/null +++ b/Codeforces/pclists/list1/I.cpp @@ -0,0 +1,27 @@ +#include +using namespace std; + +int main() { + int n, m; + cin >> n >> m; + vector> mat(n,vector(m,0)); + int r = 0, c = 0; + + for (int i = 0; i < n; ++i) { + bool hasColum = true; + for (int j = 0; j < m; ++j) { + char aux; cin >> aux; + mat[i][j] = aux-'0'; + if (mat[i][j]) { + r = max(r, j+1); + if(hasColum) { + hasColum = false; + c++; + } + } + } + } + + cout << r << "x" << c << endl; + return 0; +} diff --git a/Codeforces/pclists/list2/A.cpp b/Codeforces/pclists/list2/A.cpp new file mode 100644 index 0000000..73e8477 --- /dev/null +++ b/Codeforces/pclists/list2/A.cpp @@ -0,0 +1,73 @@ +#include +using namespace std; + +int solve(queue q, int f, int p) { + + int count = 0; + + if(f == 1) { + while(not q.empty()) { + int v = q.front(); + q.pop(); + if(v > p) { + v -= 2; + q.push(v); + count += 10; + } else + count += 5; + + } + } + + else if (f == 2) { + bool fis = false; + while(not q.empty()) { + int v = q.front(); + q.pop(); + if(not fis and v > p) { + v -= 2; + q.push(v); + count += 10; + fis = true; + } else if (not fis and v <= p) { + fis = true; + count += 5; + } else { + count += 1; + fis = false; + } + } + } + + else if(f == 3) { + for(int i = 1; not q.empty(); ++i) { + int v = q.front(); + q.pop(); + if((i%3) == 1 and v > p) { + v -= 2; + q.push(v); + count += 10; + } else if((i%3)==1 and v <= p) + count += 5; + else + count += 1; + } + } + + return count; + +} + +int main(){ + + int n, f, p; cin >> n >> f >> p; + queue q; + while(n--) { + int aux; cin >> aux; + q.push(aux); + } + + cout << solve(q,f,p) << endl; + return 0; + +} \ No newline at end of file diff --git a/Codeforces/pclists/list3/A.cpp b/Codeforces/pclists/list3/A.cpp new file mode 100644 index 0000000..7a04d91 --- /dev/null +++ b/Codeforces/pclists/list3/A.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; + +int main(){ + + int n; cin >> n; + unordered_map unmap; + while(n--) { + int a,b; cin >> a >> b; + if(a==1) unmap[b]=1; + if(a==2) cout << (unmap[b]?"Sim":"Nao") << endl; + } + + return 0; +} \ No newline at end of file diff --git a/Codeforces/pclists/list3/B.cpp b/Codeforces/pclists/list3/B.cpp new file mode 100644 index 0000000..6f107b5 --- /dev/null +++ b/Codeforces/pclists/list3/B.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; + +int main(){ + + string s1,s2; cin >> s1 >> s2; + unordered_map dic; + for(int i = 0; i < (int) s1.length(); ++i) + dic[s1[i]]=s2[i]; + + int n; cin >> n; + while(n--) { + string str, res = ""; cin >> str; + for(int i = 0; i < (int) str.length(); ++i) { + + char let = str[i]; + if(isdigit(let)) + res += let; + if(isupper(let)) + res += toupper(dic[tolower(let)]); + else + res += dic[let]; + } + for(auto i : res) + if(isdigit(i) or isalpha(i)) + cout << i; + cout << endl; + } + return 0; +} \ No newline at end of file