Skip to content

Commit 3a46a87

Browse files
committed
๐Ÿœ Study: ์„ ์ž… ์„ ์ถœ ์Šค์ผ€์ค„๋ง
1 parent 46f2a8a commit 3a46a87

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <vector>
4+
#include <queue>
5+
6+
using namespace std;
7+
8+
typedef pair<int, int> PAIR;
9+
10+
int solution(int n, vector<int> cores) {
11+
long long work;
12+
int N = cores.size();
13+
if (n <= N) return n;
14+
int bot = 0, mid, top = n * 10000 + 1;
15+
while (bot < top) {
16+
work = 0;
17+
mid = (bot + top) / 2;
18+
for (int c : cores) work += (long long)(mid / c + 1);
19+
if (work >= n) top = mid;
20+
else bot = mid + 1;
21+
}
22+
23+
work = 0;
24+
for (int c : cores) work += (long long)(top / c + 1);
25+
26+
while (true) {
27+
for (int i = N - 1; i >= 0; i--) {
28+
if (top % cores[i] == 0) {
29+
work--;
30+
if (work == n - 1) return i + 1;
31+
}
32+
}
33+
top--;
34+
}
35+
return 0;
36+
}

0 commit comments

Comments
ย (0)