diff --git a/06/1213.c++ b/06/1213.c++ new file mode 100644 index 0000000..629c3a3 --- /dev/null +++ b/06/1213.c++ @@ -0,0 +1,59 @@ +#include +#include +#include + +using namespace std; + +//1. 앞 단어부터 같은 단어가 있는지 확인한다. +//2. 순서대로 vector에 저장한다. (두 개의 같은 단어 중 한 단어만) +//3. 짝지어지지 않은 단어가 한 개 이상이라면 실패한다. +//4. vector을 정렬 후 순서대로 출력 + 단어 한 개 있다면 출력 + vector를 역순으로 출력 + +void check_ans(string s, vector ans){ + for(int i=0;i1) cout << "I'm Sorry Hansoo"; + else{ + for(auto it : ans){ + cout << it; + } + if(cnt==1){ + cout << word; + } + for(auto it=ans.rbegin();it!=ans.rend();it++){ + cout << *it; + } + } +} + +int main() +{ + ios::sync_with_stdio(false); + cin.tie(NULL); cout.tie(NULL); + + string s; + cin >> s; + + vector ans; + check_ans(s, ans); + + return 0; +} \ No newline at end of file diff --git a/06/17451.c++ b/06/17451.c++ new file mode 100644 index 0000000..19f4a20 --- /dev/null +++ b/06/17451.c++ @@ -0,0 +1,41 @@ +#include +#include + +using namespace std; +typedef long long ll; + +//1. 최소 속도값을 구하기 위해서는 뒤에서부터 봐야한다. +//2. 기준값을 잡아서 기준값보다 큰 수라면 그 수로 기준값을 업데이트한다. +//3. 기준값보다 작은 수라면 기준값보다 큰 작은 수의 배수를 계산한 후 기준값을 업데이트한다. +//4. 최종적으로 기준값에 저장된 수가 정답이 된다. + + +ll calc(vector& v){ + ll ans=0; + for(int i=v.size()-1;i>=0;i--){ //뒤에서부터 순회 + if(ans0) tmp +=1; + ans = v[i]*tmp; + } + } + return ans; +} + +int main() +{ + ios::sync_with_stdio(false); + cin.tie(NULL); cout.tie(NULL); + + int n; + cin >> n; + + vector v(n,0); + for(int i=0;i> v[i]; + } + cout << calc(v); + + return 0; +} \ No newline at end of file diff --git a/06/18111.c++ b/06/18111.c++ new file mode 100644 index 0000000..f06beb8 --- /dev/null +++ b/06/18111.c++ @@ -0,0 +1,69 @@ +#include +#include +#include + +using namespace std; +typedef long long ll; +typedef pair p; +const int MAX = 257; + +//1. 초기의 높이값의 빈도수를 vector에 저장한다. +//2. 0부터 256까지 기준 높이를 정해, 빈도수를 저장한 vector를 사용하여 시간을 모두 구한다. +//3. 시간과 높이를 함께 저장하여 sort를 통해 조건대로 정렬한다. + +bool cmp(p& p1, p& p2){ + if(p1.first!=p2.first) return p1.first < p2.first; + return p1.second > p2.second; +} + +p build(int block, vector height, int max){ + vector

ans; + for(int i=0;i<=max;i++){ + int b = block; + ll t=0; + for(int j=i+1;j<=max;j++){ //기준 높이보다 높다면 + if(height[j]>0){ + ll tmp = (j-i)*height[j]; + t+=2*tmp; + b+=tmp; + } + } + for(int k=i-1;k>=0;k--){ //기준 높이보다 낮다면 + if(height[k]>0){ + ll tmp = (i-k)*height[k]; + t+=tmp; + b-=tmp; + } + } + if(b<0) continue; + ans.push_back(make_pair(t,i)); + } + sort(ans.begin(), ans.end(),cmp); + return ans[0]; +} + + +int main() +{ + ios::sync_with_stdio(false); + cin.tie(NULL); cout.tie(NULL); + + int n,m,b; + cin >> n >> m >> b; + + vector v(MAX,0); + vector

height; + int max=0; + while(n--){ //초기 블록 높이를 빈도수로 저장 + for(int i=0;i> j; + if(max