-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b294b9
commit f18bf45
Showing
12 changed files
with
319 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |