# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1000219 |
2024-06-17T06:31:06 Z |
vicvic |
Snowball (JOI21_ho_t2) |
C++11 |
|
1 ms |
344 KB |
#include <iostream>
#include <climits>
using namespace std;
const int nmax=2e5;
long long int n, nrq, mx[nmax+5], mn[nmax+5], poz[nmax+5], rez[nmax+5];
int main()
{
cin >> n >> nrq;
for (int i=1;i<=n;i++)
{
cin >> poz[i];
}
long long int dep=0;
for (int i=1;i<=nrq;i++)
{
long long int val;
cin >> val;
dep+=val;
mn[i]=min (mn[i-1], dep);
mx[i]=max (mx[i-1], dep);
}
rez[1]+=abs (mn[nrq]);
rez[n]+=mx[nrq];
for (int i=2;i<=n;i++)
{
long long int st=1, dr=nrq, ret=0;
while (st<=dr)
{
int mij = (st+dr) >> 1;
if (poz[i]-poz[i-1]>mx[mij]-mn[mij])
{
ret=mij;
st=mij+1;
}
else dr=mij-1;
}
rez[i-1]+=mx[ret];
if (ret+1<=n && mx[ret+1]>mx[ret])
{
rez[i-1]+=poz[i]-poz[i-1]-(mx[ret]-mn[ret]);
}
else if (ret+1<=n)
{
rez[i]+=poz[i]-poz[i-1]-(mx[ret]-mn[ret]);
}
rez[i]+=abs (mn[ret]);
}
for (int i=1;i<=n;i++)
{
cout << rez[i] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |