Submission #150054

# Submission time Handle Problem Language Result Execution time Memory
150054 2019-09-01T07:37:56 Z Cafe Maru(#3599, bryan, pps789, kazel) Organizing the Best Squad (FXCUP4_squad) C++17
19 / 100
170 ms 11004 KB
#include "squad.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> a,d,p;
void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
    a = A;
    d = D;
    p = P;
}

pair<ll, ll> ad[2], bd[2];
long long BestSquad(int X, int Y){
    int n = a.size();
    for(int i=0;i<n;i++) {
        pair<ll,ll> ta = {1LL*X*a[i] + 1LL*Y*p[i], i};
        if(ta > ad[0]) {
            ad[1] = ad[0];
            ad[0] = ta;
        } else if (ta > ad[1]) {
            ad[1] = ta;
        }
        pair<ll,ll> tb = {1LL*X*d[i] + 1LL*Y*p[i], i};
        if (tb > bd[0]) {
            bd[1] = bd[0];
            bd[0] = tb;
        } else if (tb > bd[1]) {
            bd[1] = tb;
        }
    }
    if (ad[0].second != bd[0].second) {
        return ad[0].first + bd[0].first;
    } else {
        return max(ad[0].first + bd[1].first, ad[1].first+bd[0].first);
    }
}


/*
void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
	int N = A.size();
}

long long BestSquad(int X, int Y){
	return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 170 ms 11000 KB Output is correct
4 Correct 165 ms 10872 KB Output is correct
5 Correct 17 ms 1024 KB Output is correct
6 Correct 167 ms 11004 KB Output is correct
7 Correct 164 ms 11000 KB Output is correct
8 Correct 164 ms 11000 KB Output is correct
# 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 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 170 ms 11000 KB Output is correct
4 Correct 165 ms 10872 KB Output is correct
5 Correct 17 ms 1024 KB Output is correct
6 Correct 167 ms 11004 KB Output is correct
7 Correct 164 ms 11000 KB Output is correct
8 Correct 164 ms 11000 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -