# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
935171 |
2024-02-28T18:44:19 Z |
Rux007 |
Self Study (JOI22_ho_t2) |
C++14 |
|
197 ms |
29668 KB |
#include <iostream>
#include <queue>
using namespace std;
const int nmax = 300005;
unsigned long long n, m, a[nmax], b[nmax], v[nmax];
priority_queue< pair<unsigned long long, unsigned long long> > H, H2;
int main()
{
cin >> n >> m;
for(int i = 1; i <= n; i ++)
cin >> a[i];
for(int i = 1; i <= n; i ++)
{
cin >> b[i];
v[i] = max(a[i], b[i]);
}
for(int i = 1; i <= n; i ++)
{
H.push({v[i] * m, i});
H2.push({-v[i] * m , i});
}
int ok = 1;
while(ok)
{
unsigned long long maxi = H.top().first;
unsigned long long pozmax = H.top().second;
unsigned long long mini = -H2.top().first;
unsigned long long pozmin = H2.top().second;
if(maxi - v[pozmax] <= mini)
{
ok = 0;
continue;
}
maxi -= v[pozmax];
if(v[pozmin] == a[pozmin])
mini += b[pozmin];
else
mini += a[pozmin];
H.pop(); H2.pop();
H.push({maxi, pozmax});
H2.push({-mini, pozmin});
}
cout << -H2.top().first;
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
14 | for(int i = 1; i <= n; i ++)
| ~~^~~~
Main.cpp:17:22: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
17 | for(int i = 1; i <= n; i ++)
| ~~^~~~
Main.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
23 | for(int i = 1; i <= n; i ++)
| ~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4544 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
3 ms |
4864 KB |
Output is correct |
11 |
Correct |
181 ms |
29668 KB |
Output is correct |
12 |
Correct |
174 ms |
26344 KB |
Output is correct |
13 |
Correct |
142 ms |
27412 KB |
Output is correct |
14 |
Correct |
146 ms |
26344 KB |
Output is correct |
15 |
Correct |
1 ms |
4440 KB |
Output is correct |
16 |
Correct |
89 ms |
22184 KB |
Output is correct |
17 |
Correct |
197 ms |
29100 KB |
Output is correct |
18 |
Correct |
175 ms |
27672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
89 ms |
22184 KB |
Output is correct |
3 |
Correct |
197 ms |
29100 KB |
Output is correct |
4 |
Correct |
175 ms |
27672 KB |
Output is correct |
5 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4544 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
3 ms |
4864 KB |
Output is correct |
11 |
Correct |
181 ms |
29668 KB |
Output is correct |
12 |
Correct |
174 ms |
26344 KB |
Output is correct |
13 |
Correct |
142 ms |
27412 KB |
Output is correct |
14 |
Correct |
146 ms |
26344 KB |
Output is correct |
15 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4544 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
3 ms |
4864 KB |
Output is correct |
11 |
Correct |
181 ms |
29668 KB |
Output is correct |
12 |
Correct |
174 ms |
26344 KB |
Output is correct |
13 |
Correct |
142 ms |
27412 KB |
Output is correct |
14 |
Correct |
146 ms |
26344 KB |
Output is correct |
15 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |