# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1099786 |
2024-10-12T05:17:05 Z |
model_code |
Nile (IOI24_nile) |
C++17 |
|
2000 ms |
14520 KB |
// time_limit/hazem_slow_uniqueD_times_CC.cpp
#include "bits/stdc++.h"
#include "nile.h"
using namespace std;
const int INF = 1e9;
vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) {
int n = W.size();
int q = E.size();
vector<int> ordW(n);
iota(ordW.begin() ,ordW.end() ,0);
sort(ordW.begin() ,ordW.end() ,[&](int i ,int j){
return W[i] < W[j];
});
vector <int> ordE(q);
iota(ordE.begin() ,ordE.end() ,0);
sort(ordE.begin() ,ordE.end() ,[&](int i ,int j){
return E[i] < E[j];
});
vector<int> w(n), c(n);
for(int i = 0; i < n; i++){
int j = ordW[i];
w[i] = W[j];
c[i] = A[j] - B[j];
}
vector<array<int, 3>> edges;
for(int i = 0; i < n; i++){
if(i+1 < n) edges.push_back({w[i+1] - w[i], i, 1});
if(i+2 < n) edges.push_back({w[i+2] - w[i], i, 0});
}
sort(edges.rbegin(), edges.rend());
set<int> act;
vector<int> len(n);
vector<array<int, 3>> mnc(n);
for(int i = 0; i < n; i++){
act.insert(i);
len[i] = 1;
mnc[i] = {INF, INF, INF};
mnc[i][i % 2] = c[i];
}
auto cost = [&](int i){
int idx = mnc[i][i % 2] < mnc[i][2]? (i % 2) : 2;
return mnc[i][idx] * (len[i] % 2);
};
auto mrg = [&](int i){
int j = *prev(act.upper_bound(i));
int k = i + 1;
act.erase(k);
len[j] += len[k];
for(int p = 0; p < 3; p++)
mnc[j][p] = min(mnc[j][p], mnc[k][p]);
};
auto upd = [&](int i){
int j = *prev(act.upper_bound(i));
mnc[j][2] = min(mnc[j][2], c[i]);
};
auto calc = [&](){
long long tot = 0;
for(int i : act)
tot += cost(i);
return tot;
};
long long ans = calc();
vector<long long> R(q, accumulate(B.begin(), B.end(), 0LL));
for(int i = 0; i < q; i++){
bool edge_added = false;
while(!edges.empty() && edges.back()[0] <= E[ordE[i]]){
auto [_, x, t] = edges.back(); edges.pop_back();
if(t) mrg(x);
else upd(x + 1);
edge_added = true;
}
if(edge_added)
ans = calc();
R[ordE[i]] += ans;
}
return R;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
12760 KB |
Output is correct |
2 |
Correct |
64 ms |
12488 KB |
Output is correct |
3 |
Correct |
71 ms |
12480 KB |
Output is correct |
4 |
Correct |
62 ms |
12996 KB |
Output is correct |
5 |
Correct |
60 ms |
12736 KB |
Output is correct |
6 |
Correct |
61 ms |
12504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
12480 KB |
Output is correct |
2 |
Correct |
68 ms |
12484 KB |
Output is correct |
3 |
Correct |
98 ms |
12484 KB |
Output is correct |
4 |
Correct |
93 ms |
12544 KB |
Output is correct |
5 |
Correct |
80 ms |
12480 KB |
Output is correct |
6 |
Correct |
101 ms |
12516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
604 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
668 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
67 ms |
12760 KB |
Output is correct |
8 |
Correct |
64 ms |
12488 KB |
Output is correct |
9 |
Correct |
71 ms |
12480 KB |
Output is correct |
10 |
Correct |
62 ms |
12996 KB |
Output is correct |
11 |
Correct |
60 ms |
12736 KB |
Output is correct |
12 |
Correct |
61 ms |
12504 KB |
Output is correct |
13 |
Correct |
64 ms |
12480 KB |
Output is correct |
14 |
Correct |
68 ms |
12484 KB |
Output is correct |
15 |
Correct |
98 ms |
12484 KB |
Output is correct |
16 |
Correct |
93 ms |
12544 KB |
Output is correct |
17 |
Correct |
80 ms |
12480 KB |
Output is correct |
18 |
Correct |
101 ms |
12516 KB |
Output is correct |
19 |
Correct |
2 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
2 ms |
604 KB |
Output is correct |
23 |
Correct |
2 ms |
668 KB |
Output is correct |
24 |
Correct |
2 ms |
604 KB |
Output is correct |
25 |
Correct |
70 ms |
12492 KB |
Output is correct |
26 |
Correct |
75 ms |
13024 KB |
Output is correct |
27 |
Correct |
94 ms |
12484 KB |
Output is correct |
28 |
Correct |
95 ms |
12484 KB |
Output is correct |
29 |
Correct |
95 ms |
12604 KB |
Output is correct |
30 |
Correct |
103 ms |
12488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
12480 KB |
Output is correct |
2 |
Correct |
68 ms |
12484 KB |
Output is correct |
3 |
Correct |
98 ms |
12484 KB |
Output is correct |
4 |
Correct |
93 ms |
12544 KB |
Output is correct |
5 |
Correct |
80 ms |
12480 KB |
Output is correct |
6 |
Correct |
101 ms |
12516 KB |
Output is correct |
7 |
Execution timed out |
2027 ms |
14520 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
67 ms |
12760 KB |
Output is correct |
9 |
Correct |
64 ms |
12488 KB |
Output is correct |
10 |
Correct |
71 ms |
12480 KB |
Output is correct |
11 |
Correct |
62 ms |
12996 KB |
Output is correct |
12 |
Correct |
60 ms |
12736 KB |
Output is correct |
13 |
Correct |
61 ms |
12504 KB |
Output is correct |
14 |
Correct |
64 ms |
12480 KB |
Output is correct |
15 |
Correct |
68 ms |
12484 KB |
Output is correct |
16 |
Correct |
98 ms |
12484 KB |
Output is correct |
17 |
Correct |
93 ms |
12544 KB |
Output is correct |
18 |
Correct |
80 ms |
12480 KB |
Output is correct |
19 |
Correct |
101 ms |
12516 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
2 ms |
604 KB |
Output is correct |
23 |
Correct |
2 ms |
604 KB |
Output is correct |
24 |
Correct |
2 ms |
668 KB |
Output is correct |
25 |
Correct |
2 ms |
604 KB |
Output is correct |
26 |
Correct |
70 ms |
12492 KB |
Output is correct |
27 |
Correct |
75 ms |
13024 KB |
Output is correct |
28 |
Correct |
94 ms |
12484 KB |
Output is correct |
29 |
Correct |
95 ms |
12484 KB |
Output is correct |
30 |
Correct |
95 ms |
12604 KB |
Output is correct |
31 |
Correct |
103 ms |
12488 KB |
Output is correct |
32 |
Execution timed out |
2027 ms |
14520 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |