-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1026bj.cpp
More file actions
61 lines (48 loc) · 884 Bytes
/
1026bj.cpp
File metadata and controls
61 lines (48 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int A[55];
int B[55];
int S() {
int s=0;
for (int i = 0; i < n; i++) {
s += A[i] * B[i];
}
return s;
}
bool cmp(int a,int b){
return a > b;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int mn = 101;
cin >> n;
for(int i=0;i<n;i++) {
cin >> A[i];
}
for (int i = 0; i < n; i++) {
cin >> B[i];
}
//최솟값 찾기
//초기) 왼쪽으로 한칸씩 이동해서 재배열한 최솟값 구하기 그러나 생각못한 케이스 존재
// B의 작은 수에 A큰거 배치해서 곱해
sort(A, A + n); //오름차순
sort(B, B + n, cmp);//내림차순
mn = S();
cout << mn;
return 0;
}
/*
for (int count = 0; count < n;count++) {
//S값 계산
mn = min(mn, S());
//A 재배열
int tmp = A[0];
for (int i = 0; i <= n - 2; i++) {
A[i] = A[i + 1];
}
A[n - 1] = tmp;
}
*/