Skip to content
Snippets Groups Projects
Commit 6708e233 authored by 김시환's avatar 김시환
Browse files

22.02.15

parent 9c28d6ad
No related branches found
No related tags found
No related merge requests found
#include<iostream>
#include<string>
using namespace std;
int main()
{
string A = "AAAA";
string B = "BB";
string input, output = "";
cin >> input;
int s = 0;
int flag = 0;
for(int i=0;i<input.length();i++)
{
if(input[i] == 'X')
continue;
int len = i - s;
if(len % 2 == 1)
{
flag = 1;
break;
}
int four, two;
four = len/4;
len -= four * 4;
two = len/2;
for(int i=0;i<four;i++)
output += A;
for(int i=0;i<two;i++)
output += B;
output += ".";
s = i + 1;
}
int len = input.length() - s;
if(len % 2 == 1)
{
flag = 1;
}
else
{
int four, two;
four = len/4;
len -= four * 4;
two = len/2;
for(int i=0;i<four;i++)
output += A;
for(int i=0;i<two;i++)
output += B;
}
if(flag == 1)
cout << -1 << endl;
else
cout << output << endl;
}
\ No newline at end of file
#include<iostream>
using namespace std;
int main()
{
int N;
cin >> N;
int five, two;
five = N/5;
N -= five * 5;
if(N % 2 == 0)
two = N/2;
else
{
five--;
N+=5;
two = N/2;
}
if(five < 0)
cout << -1 << endl;
else
cout << five + two << endl;
}
\ No newline at end of file
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
int N;
cin >> N;
vector<int> v;
for(int i=0;i<N;i++)
{
int a;
cin >> a;
v.push_back(a);
}
sort(v.begin(), v.end(), greater<>());
int Max = 0;
for(int i=0;i<v.size();i++)
{
int now = (i + 1) * v[i];
if(Max < now)
Max = now;
}
cout << Max << endl;
}
\ No newline at end of file
......@@ -27,4 +27,7 @@
### 22.01.19
* Tree 끝
### 22.02.15
* Greedy 시작
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment