답안 #824659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824659 2023-08-14T08:36:11 Z 박영우(#10362) Winter Driving (CCO19_day1problem3) C++17
0 / 25
174 ms 5492 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;
	v1.push_back(0);
	for (i = 2; i <= 19; i++) {
		int s = v1.size();
		for (int j = 0; j < s; j++) v1.push_back(v1[j] + A[i]);
	}
	v2.push_back(0);
	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 - 1000; i <= ind + 1000; 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];
	cout << mx;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:48:62: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for (i = ind - 1000; i <= ind + 1000; i++) if (0 <= i && i < v2.size()) mx = max(mx, (v + v2[ind]) * (S - v - v2[ind]));
      |                                                            ~~^~~~~~~~~~~
Main.cpp:24:9: warning: unused variable 'p' [-Wunused-variable]
   24 |  int i, p;
      |         ^
# 결과 실행 시간 메모리 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 596 KB Execution killed with signal 6
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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 5452 KB Output is correct
2 Correct 167 ms 5492 KB Output is correct
3 Correct 158 ms 5452 KB Output is correct
4 Correct 162 ms 5452 KB Output is correct
5 Correct 155 ms 5452 KB Output is correct
6 Correct 148 ms 5452 KB Output is correct
7 Correct 113 ms 5452 KB Output is correct
8 Correct 151 ms 5456 KB Output is correct
9 Correct 151 ms 5452 KB Output is correct
10 Correct 155 ms 5452 KB Output is correct
11 Correct 169 ms 5484 KB Output is correct
12 Correct 156 ms 5452 KB Output is correct
13 Correct 155 ms 5452 KB Output is correct
14 Correct 165 ms 5452 KB Output is correct
15 Incorrect 174 ms 5452 KB Output isn't correct
16 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 -