We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 46f2a8a commit 3a46a87Copy full SHA for 3a46a87
1 file changed
โing-eoking/์ ์ ์ ์ถ ์ค์ผ์ค๋ง.ccโ
@@ -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
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