#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
void read(T &x)
{
x = 0;
register int c;
while ((c = getchar()) && (c > '9' || c < '0'))
;
for (; c >= '0' && c <= '9'; c = getchar())
x = x * 10 + c - '0';
}
constexpr bool typetest = 0;
constexpr int N = 2e3 + 5;
constexpr int Inf = 1e9 + 7;
ll scheduling_cost(vector<int> p, vector<int> u, vector<int> d)
{
int n = p.size();
if (count(p.begin(), p.end(), 0) == n - 1)
{
vector<int> id(n);
for (int i = 0; i < n; ++i)
id[i] = i;
sort(id.begin() + 1, id.end(), [&](const int &x, const int &y)
{ return d[x] * u[y] < d[y] * u[x]; });
ll ans(0), time(0);
for (int i = 0; i < n; ++i)
{
time += d[id[i]];
//cout << id[i] << " " << time << "\n";
ans += u[id[i]] * time;
}
return ans;
}
return Inf;
}
Compilation message
job.cpp: In function 'void read(T&)':
job.cpp:12:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
12 | register int c;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
83 ms |
5708 KB |
Output is correct |
5 |
Correct |
82 ms |
5692 KB |
Output is correct |
6 |
Correct |
82 ms |
5684 KB |
Output is correct |
7 |
Correct |
81 ms |
5688 KB |
Output is correct |
8 |
Correct |
96 ms |
5688 KB |
Output is correct |
9 |
Correct |
79 ms |
5696 KB |
Output is correct |
10 |
Correct |
82 ms |
5772 KB |
Output is correct |
11 |
Correct |
83 ms |
5684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
5 ms |
460 KB |
Output is correct |
6 |
Correct |
92 ms |
5756 KB |
Output is correct |
7 |
Correct |
105 ms |
5708 KB |
Output is correct |
8 |
Correct |
88 ms |
5720 KB |
Output is correct |
9 |
Correct |
87 ms |
5688 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
4 ms |
460 KB |
Output is correct |
13 |
Correct |
4 ms |
460 KB |
Output is correct |
14 |
Correct |
99 ms |
5820 KB |
Output is correct |
15 |
Correct |
91 ms |
5700 KB |
Output is correct |
16 |
Correct |
86 ms |
5704 KB |
Output is correct |
17 |
Correct |
89 ms |
5780 KB |
Output is correct |
18 |
Correct |
89 ms |
5692 KB |
Output is correct |
19 |
Correct |
97 ms |
5692 KB |
Output is correct |
20 |
Correct |
91 ms |
5696 KB |
Output is correct |
21 |
Correct |
92 ms |
5696 KB |
Output is correct |
22 |
Correct |
88 ms |
5776 KB |
Output is correct |
23 |
Correct |
88 ms |
5700 KB |
Output is correct |
24 |
Correct |
87 ms |
5708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |