https://www.acmicpc.net/problem/2217
2217번: 로프
N(1 ≤ N ≤ 100,000)개의 로프가 있다. 이 로프를 이용하여 이런 저런 물체를 들어올릴 수 있다. 각각의 로프는 그 굵기나 길이가 다르기 때문에 들 수 있는 물체의 중량이 서로 다를 수도 있다. 하
www.acmicpc.net
흠 그리드 문제는 진짜 좀 많이 어렵네요
난이도 낮음에도 조금 생각을 많이 하네요
#include <iostream>
#include <vector>
#include <queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<map>
using namespace std;
struct Point {
int s, e, t, cnt;
char c;
};
void Prints(vector<vector<int>>maps, int n, int m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[i][j];
}
cout << endl;
}
cout << endl;
}
void Prints(vector<vector<bool>>maps, int n, int m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[i][j];
}
cout << endl;
}
cout << endl;
}
void Prints(vector<vector<char>>maps, int n, int m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[i][j];
}
cout << endl;
}
cout << endl;
}
void Prints(vector<vector<vector<char>>>maps, int n, int m, int k) {
for (int t = 0; t < k; t++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[t][i][j];
}
cout << endl;
}
cout << endl;
}
cout << endl;
}
void Prints(vector<vector<vector<bool>>>maps, int n, int m, int k) {
for (int t = 0; t < k; t++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[t][i][j];
}
cout << endl;
}
cout << endl;
}
cout << endl;
}
struct Data {
int score;
int index;
};
struct Word {
std::string word;
int count;
};
bool compare(const Data &a, const Data &b) {
return a.score > b.score;
}
int main() {
int n;
cin >> n;
vector<int>ropes;
for (int i = 0; i < n; i++) {
int rope;
cin >> rope;
ropes.push_back(rope);
}
sort(ropes.begin(), ropes.end(),greater<>());
int maxw;
maxw = ropes[0];//15
for (int i = 0; i < n; i++) {
if (maxw <= ropes[i] * (i+1)) {
maxw = ropes[i] * (i+1);
}
}
cout << maxw;
return 0;
}