// correct/solution-st1-star.cpp
#include "deliveries.h"
#include <set>
#include <iostream>
#define MAXN 101000
using namespace std;
long long N, TIME, sumW, ans;
long long T[MAXN];
long long W[MAXN];
set<pair<long long, int>> spikeW;
void init(int NN, std::vector<int> /*UU*/, std::vector<int> /*VV*/, std::vector<int> TT, std::vector<int> WW){
N = NN;
for(int i=0; i<N-1; i++){
T[i+1] = TT[i];
}
for(int i=0; i<N; i++){
W[i] = WW[i];
}
W[0]++;
for(int i=1; i<N; i++){
sumW += W[i];
spikeW.insert({W[i],i});
ans += W[i] * T[i];
}
sumW += W[0];
}
long long max_time(int S, int X){
if(S==0) X++;
sumW -= W[S];
ans -= W[S] * T[S];
spikeW.erase({W[S],S});
W[S] = X;
sumW += W[S];
ans += W[S] * T[S];
spikeW.insert({W[S],S});
auto it = spikeW.end(); it--;
int id = (*it).second;
if (W[id] < (sumW+1)/2){
return 2*ans;
}
return 2*(ans - W[id] * T[id] + (sumW - W[id])*T[id]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
7640 KB |
Output is correct |
2 |
Correct |
84 ms |
7396 KB |
Output is correct |
3 |
Correct |
94 ms |
7640 KB |
Output is correct |
4 |
Correct |
85 ms |
7572 KB |
Output is correct |
5 |
Correct |
88 ms |
7692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
3rd lines differ - on the 1st token, expected: '1627540', found: '65004' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
7640 KB |
Output is correct |
2 |
Correct |
84 ms |
7396 KB |
Output is correct |
3 |
Correct |
94 ms |
7640 KB |
Output is correct |
4 |
Correct |
85 ms |
7572 KB |
Output is correct |
5 |
Correct |
88 ms |
7692 KB |
Output is correct |
6 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '45306', found: '11148' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
7640 KB |
Output is correct |
2 |
Correct |
84 ms |
7396 KB |
Output is correct |
3 |
Correct |
94 ms |
7640 KB |
Output is correct |
4 |
Correct |
85 ms |
7572 KB |
Output is correct |
5 |
Correct |
88 ms |
7692 KB |
Output is correct |
6 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '129238', found: '7664' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
7640 KB |
Output is correct |
2 |
Correct |
84 ms |
7396 KB |
Output is correct |
3 |
Correct |
94 ms |
7640 KB |
Output is correct |
4 |
Correct |
85 ms |
7572 KB |
Output is correct |
5 |
Correct |
88 ms |
7692 KB |
Output is correct |
6 |
Incorrect |
1 ms |
340 KB |
3rd lines differ - on the 1st token, expected: '1627540', found: '65004' |
7 |
Halted |
0 ms |
0 KB |
- |