/*
ID: 5ak0
PROG:
LANG: C++11
*/
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18 + 7;
const int MAXN = 1e5 + 10;
int n;
ll h[MAXN], w[MAXN], pre[MAXN], res = INF;
ll dist(int i, int j){
return (h[i] - h[j]) * (h[i] - h[j]);
}
int main(){
ios_base::sync_with_stdio(0);
#ifndef SAKO
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
#endif // SAKO
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> h[i];
for (int i = 1; i <= n; ++i){
cin >> w[i];
pre[i] = pre[i - 1] + w[i];
}
for (int i = 2; i < n; ++i)
for (int j = i + 1; j < n; ++j)
res = min(res, pre[i] - pre[1] + pre[j] - pre[i] + pre[n] - pre[j] + dist(1, i) + dist(i, j) + dist(j, n));
cout << res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3007 ms |
3812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |