-
Notifications
You must be signed in to change notification settings - Fork 2
20-flydongwoo #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
20-flydongwoo #81
Conversation
Seol-Munhyeok
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄μ체μ μκ°μ λλ¬Έ μ€μΌμ€λ§μ΄ λ μ¬λλ€μ. μ€νμκ°μ΄ μ§§μ νλ‘μΈμ€λΆν° μ°μ μμλ‘ μ²λ¦¬νλ Shortest Job First (SJF) μ€μΌμ€λ§μ΄ κ°μ₯ μ΅μ μ λκΈ° μκ°μ μ 곡νλ€λ μ μ μκ³ μμΌλ©΄ μ½κ² ν μ μλ λ¬Έμ μμ΅λλ€.
λ°λΌμ μκ°μ μ€λ¦μ°¨μμΌλ‘ μ λ ¬ν λ€, λμ ν© λ°°μ΄μ ꡬν λ€, κ·Έ λμ ν© λ°°μ΄μ μλ λͺ¨λ μμμ ν©μ ꡬνλ μμΌλ‘ νμμ΅λλ€.
n = int(input())
lst = list(map(int, input().split()))
lst.sort()
p_sum = [0] * (n + 1)
for i in range(n):
p_sum[i + 1] = p_sum[i] + lst[i]
print(sum(p_sum))μκ³ νμ ¨μ΅λλ€!
|
μμͺ½μ μ μλ μ¬λμ λ λ§μ΄ ν©μ μ μ©λλ―λ‘, μμͺ½μ λ μ μ μκ°μ μ¬μ©νλ μΈμμ λ°°μΉν΄μΌ νλ€λ μμ΄λμ΄λ§ μλ€λ©΄ κ°λ¨ν ꡬνν μ μλ λ¬Έμ μμ΅λλ€. λ¬Έμ νΈμλλΌ κ³ μνμ ¨μ΄μ! ATM / c++#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
//freopen("test.txt", "rt", stdin);
int n, ans = 0;
cin >> n;
vector<int> arr(n);
for(int i = 0; i < n; i++)
{
cin >> arr[i];
}
sort(arr.begin(), arr.end());
for(int i = n; i > 0; i--)
{
ans += arr[n - i] * i;
}
cout << ans;
return 0;
}
|
|
μ λ κ°λ¨νκ² μΈμμ μ μ μκ°μ μ¬μ©νλ μͺ½μΌλ‘ μ λ ¬νμ¬ ν΄κ²°νμ΅λλ€. #include <bits/stdc++.h>
using namespace std;
int main() {
// freopen("input.txt", "rt", stdin);
int n; cin >> n;
vector<int> v(n);
for(int i = 0; i < n; i++) cin >> v[i];
sort(v.begin(), v.end());
vector<int> sv(n);
sv[0] = v[0];
for(int i = 1; i < n; i++) sv[i] = v[i] + sv[i-1];
int res = 0;
for(int i = 0; i < n; i++) {
res += sv[i];
}
cout << res;
return 0;
} |
π λ¬Έμ λ§ν¬
https://www.acmicpc.net/problem/11399
βοΈ μμλ μκ°
20λΆ
β¨ μλ μ½λ
μλ νμλκΉ!
μ κ° κ·Έλμ ν΄κ°μ λ°λ¦° μ¬μ΄λ νλ‘μ νΈ λ§κ° κΈ°νμ΄ λ€κ°μμ PRμ΄ λΈνλ€μ μ£μ‘ν©λλ€
μμΌλ‘ κ°κ°νμλ λ°λ¦¬μ§ μκ² μ΅λν μ΄μ¬ν νλλ‘ λ Έλ ₯ν΄λ³΄κ² μ΅λλ€!!!
μ΄λ² λ¬Έμ λ ν΄κ°μ λ―Έν μΌλ‘ μΈν΄ λμ λ§μ΄ μ¨μ ATMμ΄ κ°μ ν΄μ§ @flydongwoo λ₯Ό μν΄ μ€λΉν λ¬Έμ μ λλ€.
μ΄ λ¬Έμ λ μ μ¬λ μκ°μ΄ μ§§μμλ‘ μ 체 ν©μ΄ μμμ§λ€λ κ²μ νμ νλ©΄ μ½κ² ν μ μλ λ¬Έμ μ λλ€!
μ¬λ μλ₯Ό μ λ ₯λ°κ³
μ¬λ μλ§νΌ κ° μ¬λλ³λ‘ 걸리λ μκ°μ vector lineμ μ λ ₯λ°κ³
lineμ μ€λ¦μ°¨μ μ λ ¬ν λ€
nλ² λ°λ³΅νλ©° iλ²μ§Έ μ¬λμ΄ κ±Έλ¦¬λ μκ°μ΄ (n-i)λ² λ§νΌ ν©μ°λλ€κ³ κ³μ°ν κ².
μ νμ μΈ κ·Έλ¦¬λλ₯Ό μ°μ΅ν μ μλ λ¬Έμ μμ΅λλ€!
π μλ‘κ² μκ²λ λ΄μ©
Just do it!
μκ°νλλλ‘ νλ©΄ λλ€! μ΅μ μ κ°μ μ°Ύλ λ§ κ·Έλλ‘ κ·Έλ¦¬λ μκ³ λ¦¬μ¦!