답안 #148513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148513 2019-09-01T04:34:41 Z 욱방켜!! (twitch.tv/wookje)(#3584, kig9981, cheetose, jh05013) 최적의 팀 구성 (FXCUP4_squad) C++17
0 / 100
169 ms 12152 KB
#include "squad.h"
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
const int MX = 200002;

int N;
ll a[MX], d[MX], p[MX];
ll dpref[MX], dsuf[MX];
bool subtask2 = true;

void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
	N = A.size();
	for(int i=0; i<N; i++){
		a[i] = A[i], d[i] = D[i], p[i] = P[i];
		if(d[i] != 1) subtask2 = false;
	}
}

long long BestSquad(int X, int Y){
	if(subtask2){
		;
		// todo...
	}

	for(int i=0; i<N; i++){
		a[i] = a[i]*X + p[i]*Y;
		d[i] = d[i]*X + p[i]*Y;
	}
	dpref[0] = d[0];
	for(int i=1; i<N; i++) dpref[i] = max(d[i], dpref[i-1]);
	dsuf[N-1] = d[N-1];
	for(int i=N-2; i>=0; i--) dsuf[i] = max(d[i], dsuf[i+1]);

	// pick i!=j to maximize a[i]+d[j]
	ll ans = -1;
	for(int i=0; i<N; i++){
		ll val = a[i];
		ll dmax = -1;
		if(i) dmax = max(dmax, dpref[i-1]);
		if(i != N-1) dmax = max(dmax, dsuf[i+1]);
		ans = max(ans, val+dmax);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Runtime error 169 ms 12152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Runtime error 169 ms 12152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -