답안 #824639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824639 2023-08-14T08:28:46 Z 박영우(#10362) Winter Driving (CCO19_day1problem3) C++17
0 / 25
1 ms 644 KB
#include <bits/stdc++.h>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 2020
#define MAXS 20
#define INF 1000000010
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 998244353
vector<int> adj[MAX];
ll A[MAX];
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	int i, p;
	for (i = 1; i <= N; i++) cin >> A[i];
	for (i = 2; i <= N; i++) cin >> p, adj[p].push_back(i), adj[i].push_back(p);
	assert(N == 37);
	ll S = 0;
	for (i = 2; i <= 37; i++) S += A[i];
	vector<ll> v1, v2;
	for (i = 2; i <= 19; i++) {
		int s = v1.size();
		for (int j = 0; j < s; j++) v1.push_back(v1[j] + A[i]);
	}
	for (i = 20; i <= 37; i++) {
		int s = v2.size();
		for (int j = 0; j < s; j++) v2.push_back(v2[j] + A[i]);
	}
	sort(v1.begin(), v1.end());
	v1.erase(unique(v1.begin(), v1.end()), v1.end());
	sort(v2.begin(), v2.end());
	v2.erase(unique(v2.begin(), v2.end()), v2.end());
	ll mx = 0;
	for (auto v : v1) {
		int ind = lower_bound(v2.begin(), v2.end(), S / 2 - v) - v2.begin();
		for (i = ind - 10; i <= ind + 10; i++) if (0 <= i && i < v2.size()) mx = max(mx, (v + v2[ind]) * (S - v - v2[ind]));
	}
	for (i = 2; i <= 37; i++) mx += A[1] * A[i];
	for (i = 1; i <= 37; i++) mx += (A[i] - 1) * A[i];
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:46:58: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for (i = ind - 10; i <= ind + 10; i++) if (0 <= i && i < v2.size()) mx = max(mx, (v + v2[ind]) * (S - v - v2[ind]));
      |                                                        ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 644 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 644 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -