답안 #150752

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150752 2019-09-01T08:53:34 Z TLEWA맞(#3625, H_Squad, sungjune222, str0ct) 최적의 팀 구성 (FXCUP4_squad) C++17
19 / 100
3000 ms 11004 KB
#include "squad.h"
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define inf 1e18
typedef long long LL;
int n;
int a[300010], d[300010], p[300010];
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];
    }
}
long long BestSquad(int X, int Y){
    LL maxx11=0, maxx21=0, maxx12=0, maxx22=0;
    int maxnum1, maxnum2;
    for(int i=0; i<n; i++){
        if(maxx12<(LL)X*a[i]+(LL)Y*p[i]){
            if(maxx11<(LL)X*a[i]+(LL)Y*p[i]){
                maxx12=maxx11;
                maxx11=(LL)X*a[i]+(LL)Y*p[i];
                maxnum1=i;
            }
            else maxx12=(LL)X*a[i]+(LL)Y*p[i];
        }
    }
    for(int i=0; i<n; i++){
        if(maxx22<(LL)X*d[i]+(LL)Y*p[i]){
            if(maxx21<(LL)X*d[i]+(LL)Y*p[i]){
                maxx22=maxx21;
                maxx21=(LL)X*d[i]+(LL)Y*p[i];
                maxnum2=i;
            }
            else maxx22=(LL)X*d[i]+(LL)Y*p[i];
        }
    }
    if(maxnum1!=maxnum2)return maxx11+maxx21;
    return max(maxx11+maxx22, maxx12+maxx21);
}

Compilation message

squad.cpp: In function 'long long int BestSquad(int, int)':
squad.cpp:41:5: warning: 'maxnum1' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(maxnum1!=maxnum2)return maxx11+maxx21;
     ^~
squad.cpp:41:5: warning: 'maxnum2' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 170 ms 11000 KB Output is correct
4 Correct 180 ms 10876 KB Output is correct
5 Correct 16 ms 1024 KB Output is correct
6 Correct 167 ms 11000 KB Output is correct
7 Correct 163 ms 10872 KB Output is correct
8 Correct 178 ms 11004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 31 ms 500 KB Output is correct
3 Execution timed out 3096 ms 11000 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 170 ms 11000 KB Output is correct
4 Correct 180 ms 10876 KB Output is correct
5 Correct 16 ms 1024 KB Output is correct
6 Correct 167 ms 11000 KB Output is correct
7 Correct 163 ms 10872 KB Output is correct
8 Correct 178 ms 11004 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 31 ms 500 KB Output is correct
11 Execution timed out 3096 ms 11000 KB Time limit exceeded
12 Halted 0 ms 0 KB -