Skip to content

Commit

Permalink
cp lists 1,2,3
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanashii76 authored May 27, 2024
1 parent 3b294b9 commit f18bf45
Show file tree
Hide file tree
Showing 12 changed files with 319 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Codeforces/pclists/list1/A.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <bits/stdc++.h>
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;
}
21 changes: 21 additions & 0 deletions Codeforces/pclists/list1/B.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <bits/stdc++.h>
using namespace std;

int main(){

int n; cin >> n;
vector<int> 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;
}
14 changes: 14 additions & 0 deletions Codeforces/pclists/list1/C.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <bits/stdc++.h>
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;
}
23 changes: 23 additions & 0 deletions Codeforces/pclists/list1/D.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <bits/stdc++.h>
using namespace std;

int main(){

int n; cin >> n;
vector<string> names;
while(n--) {
string aux; cin >> aux;
names.emplace_back(aux);
}

vector<string> 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;
}
25 changes: 25 additions & 0 deletions Codeforces/pclists/list1/E.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <bits/stdc++.h>
using namespace std;

int main(){

int n; cin >> n;
vector<int> 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;

}
28 changes: 28 additions & 0 deletions Codeforces/pclists/list1/F.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <bits/stdc++.h>
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<int> 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;
}
30 changes: 30 additions & 0 deletions Codeforces/pclists/list1/G.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <bits/stdc++.h>
using namespace std;

bool dist_nums(int n) {

set<int> 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;
}
16 changes: 16 additions & 0 deletions Codeforces/pclists/list1/H.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <bits/stdc++.h>
using namespace std;

int main(){

int n,x,y; cin >> n >> x >> y;
pair<int,int> 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;
}
27 changes: 27 additions & 0 deletions Codeforces/pclists/list1/I.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <bits/stdc++.h>
using namespace std;

int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> mat(n,vector<int>(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;
}
73 changes: 73 additions & 0 deletions Codeforces/pclists/list2/A.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include <bits/stdc++.h>
using namespace std;

int solve(queue<int> 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<int> q;
while(n--) {
int aux; cin >> aux;
q.push(aux);
}

cout << solve(q,f,p) << endl;
return 0;

}
15 changes: 15 additions & 0 deletions Codeforces/pclists/list3/A.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <bits/stdc++.h>
using namespace std;

int main(){

int n; cin >> n;
unordered_map<int,bool> 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;
}
30 changes: 30 additions & 0 deletions Codeforces/pclists/list3/B.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <bits/stdc++.h>
using namespace std;

int main(){

string s1,s2; cin >> s1 >> s2;
unordered_map<char,char> 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;
}

0 comments on commit f18bf45

Please sign in to comment.