Skip to content

Commit

Permalink
2020.04.26.
Browse files Browse the repository at this point in the history
1330 두수 비교하기
2108 통계학
2750 수 정렬하기
2798 블랙잭
  • Loading branch information
witheunjin committed Apr 26, 2020
1 parent a78d884 commit 37203d6
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 4 deletions.
15 changes: 15 additions & 0 deletions BaekJoon/1330_두수비교하기.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
using namespace std;

string compare(int a, int b) {
if(a>b) return ">";
if(a<b) return "<";
return "==";
}
int main() {
int A;
int B;
cin>>A>>B;
cout<<compare(A,B);
return 0;
}
46 changes: 46 additions & 0 deletions BaekJoon/2108_통계학.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
int N; cin>>N;
vector<int> v;
int input = 0;
double sum = 0.0;
int min = 4001;
int max = -4001;
for(int i=0;i<N;++i){
cin>>input;
sum+=input;
if(min>input) min = input;
if(max<input) max = input;
v.push_back(input);
}
int mid = (N-1)/2;
sort(v.begin(),v.end());
cout<<(round)(sum/N)<<endl;
cout<<v[mid]<<endl;
int most = 0;
int temp = 0;
int cnt = 0;
int c = 0;
for(int i=0;i<N;++i) {
if(i!=0 && v[i-1]==v[i]) ++cnt;
else cnt = 1;
if(most<cnt) {
most = cnt;
temp = i;
c=1;

}
else if(most==cnt && c==1) {
temp = i;
++c;
}
}
cout<<v[temp]<<endl;
cout<<max-min<<endl;
return 0;
}
20 changes: 20 additions & 0 deletions BaekJoon/2750_수정렬하기.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
int n=0;
cin>>n;
vector<int> v;
int input = 0;
for(int i=0;i<n;++i) {
cin>>input;
v.push_back(input);
}
sort(v.begin(),v.end());
for(int i=0;i<n;++i) {
cout<<v[i]<<endl;
}
return 0;
}
34 changes: 34 additions & 0 deletions BaekJoon/2798_블랙잭.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N; cin>>N;
int M; cin>>M;
vector<int> card;
int input=0;
int min = 99999999;
for(int i=0;i<N;++i) {
cin>>input;
card.push_back(input);
if(min>input) min = input;
}
int sum=0;
int maxSum=0;
for(int i=0;i<N-2;++i) {
for(int j=i+1;j<N-1;++j) {
if(sum==-1) break;
if(card[i]+card[j]>M) continue;
if(card[i]+card[j]+min>M) continue;
if(card[i]+card[j]+min==M) {sum = -1; break;}
for(int k=j+1;k<N;++k) {
sum = card[i]+card[j]+card[k];
if(sum == M) {sum = -1; break;}
if(sum>M) continue;
if(sum>maxSum) maxSum=sum;
}
}
}
if(sum==-1) cout<<M<<endl;
else cout<<maxSum<<endl;
return 0;
}
8 changes: 4 additions & 4 deletions BaekJoon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ https://www.acmicpc.net/
|**10809**|**알파벳 찾기**|2020.04.25|1|
|**2675**|**문자열 반복**|2020.04.25|2|
|**1157**|**단어 공부**|2020.04.25|3|
|****|****|||
|****|****|||
|****|****|||
|****|****|||
|**2108**|**통계학**|2020.04.26|5|
|**2750**|**수 정렬하기**|2020.04.26|1|
|**2798**|**블랙잭**|2020.04.26|1|
|**1330**|**두 수 비교하기**|2020.04.26|1|
|****|****|||
|****|****|||
|****|****|||
Expand Down

0 comments on commit 37203d6

Please sign in to comment.