Submission #757626

# Submission time Handle Problem Language Result Execution time Memory
757626 2023-06-13T13:07:23 Z HoriaHaivas Snowball (JOI21_ho_t2) C++14
100 / 100
122 ms 9768 KB
/*
    "TLE is like the wind, always by my side"
    - Yasuo - 2022 -
*/
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize("Ofast")
#define int long long

using namespace std;

int v[200001];
int rightmost[200001];
int leftmost[200001];
int weight[200001];
int w[200001];

bool intervaldone (int query, int pos)
{
     if (rightmost[query]+leftmost[query]>=v[pos+1]-v[pos])
         return 1;
     return 0;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,q,i,j,poz,r,pas;
    cin >> n >> q;
    for (i=1;i<=n;i++)
    {
         cin >> v[i];
    }
    poz=0;
    for (j=1;j<=q;j++)
    {
         cin >> w[j];
         poz+=w[j];
         rightmost[j]=max(rightmost[j-1],poz);
         leftmost[j]=min(leftmost[j-1],poz);
    }
    for (j=1;j<=q;j++)
         leftmost[j]=abs(leftmost[j]);
    weight[1]+=leftmost[q];
    weight[n]+=rightmost[q];
    for (j=1;j<n;j++)
    {
         r=0;
         pas=(1<<17);
         while (pas)
         {
             if (r+pas<=q && !intervaldone(r+pas,j))
                 r+=pas;
             pas=pas/2;
         }
         r++;
         if (r==q+1)
         {
             r--;
             weight[j]+=rightmost[q];
             weight[j+1]+=leftmost[q];
         }
        else if (rightmost[r]==rightmost[r-1])
         {
             weight[j]+=rightmost[r];
             weight[j+1]+=(v[j+1]-v[j])-rightmost[r];
         }
         else
         {
             weight[j+1]+=leftmost[r];
             weight[j]+=(v[j+1]-v[j])-leftmost[r];
         }
    }
    for (j=1;j<=n;j++)
    {
         cout << weight[j] << "\n";
    }
}
# 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 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
# 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 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 25 ms 4948 KB Output is correct
21 Correct 23 ms 4952 KB Output is correct
22 Correct 24 ms 4972 KB Output is correct
23 Correct 21 ms 5004 KB Output is correct
24 Correct 30 ms 5508 KB Output is correct
25 Correct 112 ms 9676 KB Output is correct
26 Correct 114 ms 9728 KB Output is correct
27 Correct 95 ms 9528 KB Output is correct
28 Correct 109 ms 9396 KB Output is correct
29 Correct 98 ms 9292 KB Output is correct
30 Correct 94 ms 9020 KB Output is correct
31 Correct 68 ms 8488 KB Output is correct
32 Correct 68 ms 8524 KB Output is correct
33 Correct 12 ms 1248 KB Output is correct
34 Correct 98 ms 9648 KB Output is correct
35 Correct 97 ms 9520 KB Output is correct
36 Correct 93 ms 9608 KB Output is correct
37 Correct 122 ms 9448 KB Output is correct
38 Correct 100 ms 9500 KB Output is correct
39 Correct 102 ms 9408 KB Output is correct
40 Correct 75 ms 9464 KB Output is correct
41 Correct 34 ms 5016 KB Output is correct
42 Correct 65 ms 8524 KB Output is correct
43 Correct 83 ms 9740 KB Output is correct
44 Correct 28 ms 4976 KB Output is correct
45 Correct 65 ms 9528 KB Output is correct
46 Correct 93 ms 9740 KB Output is correct
47 Correct 83 ms 9768 KB Output is correct
48 Correct 88 ms 9756 KB Output is correct