A. The Fair Nut and Elevator

Solved.

签.

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 #define N 110
 5 int n, a[N];
 6 
 7 int main()
 8 {
 9     while (scanf("%d", &n) != EOF)
10     {
11         for (int i = 1; i <= n; ++i) scanf("%d", a + i);
12         int res = 1e9;
13         for (int x = 1, tmp = 0; x <= 100; ++x, res = min(res, tmp), tmp = 0) for (int i = 1; i <= n; ++i) if (a[i])
14         {
15             tmp += a[i] * (abs(x - i) + abs(i - 1) + abs(x - 1) + abs(x - 1) + abs(i - 1) + abs(x - i)); 
16         }
17         printf("%d\n", res);
18     }
19     return 0;
20 }
View Code

相关文章:

  • 2022-01-13
  • 2021-05-23
  • 2022-02-11
  • 2022-02-20
  • 2021-10-04
  • 2022-12-23
  • 2021-11-14
猜你喜欢
  • 2022-03-02
  • 2021-07-20
  • 2021-05-18
  • 2021-09-30
  • 2021-06-15
  • 2021-12-06
  • 2021-11-24
相关资源
相似解决方案