-
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.
1330 두수 비교하기 2108 통계학 2750 수 정렬하기 2798 블랙잭
- Loading branch information
1 parent
a78d884
commit 37203d6
Showing
5 changed files
with
119 additions
and
4 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,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; | ||
} |
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,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; | ||
} |
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,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; | ||
} |
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,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; | ||
} |
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