# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1099781 |
2024-10-12T05:16:06 Z |
model_code |
Nile (IOI24_nile) |
C++17 |
|
2000 ms |
5328 KB |
// time_limit/hazem_qn.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> 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];
}
w.insert(w.begin(), -INF);
c.insert(c.begin(), 0);
w.insert(w.end(), INF + INF);
c.insert(c.end(), 0);
auto solve = [&](int d){
long long tot = 0;
int j = 1, cur = INF;
for(int i = 1; i <= n; i++){
if(i % 2 == j % 2 || w[i+1] - w[i-1] <= d)
cur = min(cur, c[i]);
if(w[i+1] - w[i] > d){
tot += cur * ((i - j + 1) % 2);
j = i + 1;
cur = INF;
}
}
return tot;
};
vector<long long> R(q, accumulate(B.begin(), B.end(), 0LL));
for(int i = 0; i < q; i++)
R[i] += solve(E[i]);
return R;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
4296 KB |
Output is correct |
2 |
Correct |
23 ms |
4304 KB |
Output is correct |
3 |
Correct |
23 ms |
4308 KB |
Output is correct |
4 |
Correct |
23 ms |
4324 KB |
Output is correct |
5 |
Correct |
23 ms |
4304 KB |
Output is correct |
6 |
Correct |
30 ms |
4284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
4308 KB |
Output is correct |
2 |
Correct |
24 ms |
4304 KB |
Output is correct |
3 |
Correct |
27 ms |
4300 KB |
Output is correct |
4 |
Correct |
27 ms |
4300 KB |
Output is correct |
5 |
Correct |
27 ms |
4304 KB |
Output is correct |
6 |
Correct |
26 ms |
4300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
26 ms |
4296 KB |
Output is correct |
8 |
Correct |
23 ms |
4304 KB |
Output is correct |
9 |
Correct |
23 ms |
4308 KB |
Output is correct |
10 |
Correct |
23 ms |
4324 KB |
Output is correct |
11 |
Correct |
23 ms |
4304 KB |
Output is correct |
12 |
Correct |
30 ms |
4284 KB |
Output is correct |
13 |
Correct |
26 ms |
4308 KB |
Output is correct |
14 |
Correct |
24 ms |
4304 KB |
Output is correct |
15 |
Correct |
27 ms |
4300 KB |
Output is correct |
16 |
Correct |
27 ms |
4300 KB |
Output is correct |
17 |
Correct |
27 ms |
4304 KB |
Output is correct |
18 |
Correct |
26 ms |
4300 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
29 ms |
4300 KB |
Output is correct |
26 |
Correct |
31 ms |
4308 KB |
Output is correct |
27 |
Correct |
30 ms |
4300 KB |
Output is correct |
28 |
Correct |
30 ms |
4336 KB |
Output is correct |
29 |
Correct |
30 ms |
4312 KB |
Output is correct |
30 |
Correct |
29 ms |
4308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
4308 KB |
Output is correct |
2 |
Correct |
24 ms |
4304 KB |
Output is correct |
3 |
Correct |
27 ms |
4300 KB |
Output is correct |
4 |
Correct |
27 ms |
4300 KB |
Output is correct |
5 |
Correct |
27 ms |
4304 KB |
Output is correct |
6 |
Correct |
26 ms |
4300 KB |
Output is correct |
7 |
Execution timed out |
2082 ms |
5328 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
26 ms |
4296 KB |
Output is correct |
9 |
Correct |
23 ms |
4304 KB |
Output is correct |
10 |
Correct |
23 ms |
4308 KB |
Output is correct |
11 |
Correct |
23 ms |
4324 KB |
Output is correct |
12 |
Correct |
23 ms |
4304 KB |
Output is correct |
13 |
Correct |
30 ms |
4284 KB |
Output is correct |
14 |
Correct |
26 ms |
4308 KB |
Output is correct |
15 |
Correct |
24 ms |
4304 KB |
Output is correct |
16 |
Correct |
27 ms |
4300 KB |
Output is correct |
17 |
Correct |
27 ms |
4300 KB |
Output is correct |
18 |
Correct |
27 ms |
4304 KB |
Output is correct |
19 |
Correct |
26 ms |
4300 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
29 ms |
4300 KB |
Output is correct |
27 |
Correct |
31 ms |
4308 KB |
Output is correct |
28 |
Correct |
30 ms |
4300 KB |
Output is correct |
29 |
Correct |
30 ms |
4336 KB |
Output is correct |
30 |
Correct |
30 ms |
4312 KB |
Output is correct |
31 |
Correct |
29 ms |
4308 KB |
Output is correct |
32 |
Execution timed out |
2082 ms |
5328 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |