Submission #150609

# Submission time Handle Problem Language Result Execution time Memory
150609 2019-09-01T08:43:06 Z TLEWA맞(#3625, H_Squad, sungjune222, str0ct) Organizing the Best Squad (FXCUP4_squad) C++17
0 / 100
5 ms 384 KB
#include "squad.h"
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define inf 1e18
typedef long long LL;
int n;
vector<int> a, d, p;
void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
    n=A.size();
    a=A;
    d=D;
    p=P;
}
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*a[i]+(LL)Y*p[i]){
            if(maxx12<(LL)X*a[i]+(LL)Y*p[i]){
                maxx22=maxx21;
                maxx21=(LL)X*a[i]+(LL)Y*p[i];
                maxnum2=i;
            }
            else maxx22=(LL)X*a[i]+(LL)Y*p[i];
        }
    }
    if(maxnum1!=maxnum2)return maxx11+maxx21;
    return max(maxx11+maxx22, maxx12+maxx22);
}

Compilation message

squad.cpp: In function 'long long int BestSquad(int, int)':
squad.cpp:39:5: warning: 'maxnum1' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(maxnum1!=maxnum2)return maxx11+maxx21;
     ^~
squad.cpp:39:5: warning: 'maxnum2' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -