Submission #791597

# Submission time Handle Problem Language Result Execution time Memory
791597 2023-07-24T07:49:47 Z n3rm1n Snowball (JOI21_ho_t2) C++17
0 / 100
2 ms 340 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const long long MAXN = 2005;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
long long n, q;
long long a[MAXN], wind[MAXN];
long long moveleft[MAXN], moveright[MAXN];

void read()
{
    cin >> n >> q;
    for (long long i = 1; i <= n; ++ i)
        cin >> a[i];
    long long pos = 0;
    for (long long i = 1; i <= q; ++ i)
    {
        cin >> wind[i];
        pos += wind[i];
        moveleft[i] = min(pos, moveleft[i-1]);
        moveright[i] = max(pos, moveright[i-1]);
    }

    for (long long i = 1; i <= q; ++ i)
    {
        moveleft[i] *= -1;
       // cout << moveleft[i] << " " << moveright[i] << endl;
    }
}
long long ans[MAXN];
void solve()
{
    for (long long i = 2; i <= n; ++ i)
    {
        for (long long j = 1; j <= q; ++ j)
        {
            if(a[i-1] + moveright[j] >= a[i] - moveleft[j])
            {
               // cout << "***" << endl;
               // cout << i-1 << " " << i << " " << j << endl;
                long long segment = a[i] - a[i-1];
                long long to_first = 0, to_second = 0;
                if(wind[j] >= 0)
                {
                    to_second = moveleft[j];
                    to_first = segment - to_second;
                }
                else
                {
                    to_first = moveright[j];
                    to_second = segment - to_first;
                }
                //cout << to_first << " " << to_second << endl;
                ans[i-1] += to_first;
                ans[i] += to_second;
                break;
            }
        }
    }
    ans[1] += moveleft[q];
    ans[n] += moveright[q];
    for (long long i = 1; i <= n; ++ i)
        cout << ans[i] << " ";
    cout << endl;
}
int main()
{
    speed();

    read();
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 2 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 2 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -