Skip to content

Commit

Permalink
로프
Browse files Browse the repository at this point in the history
  • Loading branch information
yewon-yw authored Apr 17, 2022
1 parent 0f21167 commit c677140
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions greedy_algorithm/2217.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <algorithm>
using namespace std;
int rope[100000];

bool compare(int a, int b) {
return a > b;
}

int main() {
int N, maxv = 0, count = 0;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> rope[i];
}
sort(rope, rope + N, compare);
for (int i = 0; i < N; i++) {
count++;
maxv = max(rope[i] * count, maxv);
}
cout << maxv;
}

0 comments on commit c677140

Please sign in to comment.