A. The Fair Nut and Elevator
https://codeforces.com/problemset/problem/1084/A
완전탐색 문제이다.
모든 층을 탐색하면서 최소의 값을 찾는다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <bits/stdc++.h> using namespace std; int n, minv, tempmin, multi, arr[101]; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; minv = 1e9; for (int i = 0; i < n; i++) { tempmin = 0; for (int j = 0; j < n; j++) { multi = 2 * (max(j - i, i - j) + j + i); tempmin += arr[j] * multi; } minv = min(tempmin, minv); } cout << minv; return 0; } | cs |
'Competition > codeforces' 카테고리의 다른 글
Codeforces Round #524 (Div. 2) B. Margarite and the best present (0) | 2019.03.29 |
---|---|
Avito Cool Challenge 2018 A. Definite Game (0) | 2019.03.29 |
Codeforces Round #525 (Div. 2) A. Ehab and another construction problem (0) | 2019.03.29 |
Technocup 2019 - Elimination Round 4 A. Right-Left Cipher (0) | 2019.03.29 |
Codeforces Round #525 (Div. 2) B. Ehab and subtraction (0) | 2019.03.29 |