//https://www.acmicpc.net/problem/2217 |
#include <iostream> |
#include <algorithm> |
using namespace std; |
int main() |
{ |
int n,tmp; |
int rope[100001]; |
int ans=0; |
cin >> n; |
for(int i=1; i<=n; i++) |
cin >> rope[i]; |
sort(rope+1, rope+n+1); |
for(int i=1; i<=n; i++) |
{ |
tmp=(n-i+1)*rope[i]; |
if(ans<tmp) ans=tmp; |
} |
cout << ans; |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180102_2884_알람 시계 (0) | 2018.01.02 |
---|---|
180101_11047_동전0 (0) | 2018.01.01 |
171229_11399_ATM (0) | 2017.12.29 |
171228_2167_2차원 배열의 합 (0) | 2017.12.28 |
171227_2563_색종이 (0) | 2017.12.27 |
//https://www.acmicpc.net/problem/2217 |
#include <iostream> |
#include <algorithm> |
using namespace std; |
int main() |
{ |
int n,tmp; |
int rope[100001]; |
int ans=0; |
cin >> n; |
for(int i=1; i<=n; i++) |
cin >> rope[i]; |
sort(rope+1, rope+n+1); |
for(int i=1; i<=n; i++) |
{ |
tmp=(n-i+1)*rope[i]; |
if(ans<tmp) ans=tmp; |
} |
cout << ans; |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180102_2884_알람 시계 (0) | 2018.01.02 |
---|---|
180101_11047_동전0 (0) | 2018.01.01 |
171229_11399_ATM (0) | 2017.12.29 |
171228_2167_2차원 배열의 합 (0) | 2017.12.28 |
171227_2563_색종이 (0) | 2017.12.27 |