Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Unreal Engine 5
- 브루트포스
- 백트래킹
- ue5
- 다익스트라
- c++
- 유니티
- 알고리즘
- 유니온 파인드
- 수학
- 정렬
- 스택
- 백준
- 재귀
- 그래프
- 투 포인터
- 자료구조
- 문자열
- 그리디 알고리즘
- 누적 합
- 우선순위 큐
- 트리
- 다이나믹 프로그래밍
- DFS
- VR
- BFS
- XR Interaction Toolkit
- 시뮬레이션
- Team Fortress 2
- 구현
Archives
- Today
- Total
1일1알
백준 16112번 5차 전직 C++ 본문
https://www.acmicpc.net/problem/16112
16112번: 5차 전직
메이플스토리 뉴비 키파가 드디어 레벨 200을 달성하고 5차 전직이라는 시스템을 이용해 캐릭터를 더욱 강력하게 만들려고 합니다. 5차 전직을 하려면 먼저 퀘스트를 통해 아케인스톤이라는 아
www.acmicpc.net
오름차순 정렬을 하면 경험치가 높은 퀘스트를 아케인스톤들에 더 나눠서 받을 수 있다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
vector<int64> v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, k;
cin >> n >> k;
v = vector<int64>(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
sort(v.begin(), v.end());
int cnt = 0;
int64 sum = 0;
for (int i = 0; i < n; i++) {
sum += cnt * v[i];
cnt = min(cnt + 1, k);
}
cout << sum;
}
'알고리즘' 카테고리의 다른 글
백준 17827번 달팽이 리스트 C++ (0) | 2023.03.18 |
---|---|
백준 4095번 최대 정사각형 C++ (0) | 2023.03.17 |
백준 2075번 N번째 큰 수 C++ (0) | 2023.03.15 |
백준 21318번 피아노 체조 C++ (0) | 2023.03.14 |
백준 3758번 KCPC C++ (0) | 2023.03.12 |