Submission #915483

# Submission time Handle Problem Language Result Execution time Memory
915483 2024-01-24T03:25:40 Z ReLice Snowball (JOI21_ho_t2) C++14
100 / 100
78 ms 8600 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool f=0;
    if (x>y){x=y;f=1;}
    return f;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool f=0;
    if (x<y){x=y;f=1;}
    return f;
}
//void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=2e18+7;
const ll mod=1e9+7;
const ll N=1e5+7;
const ld eps=1e-9;
void solve(){
    ll i,j;
    ll n,m;
    cin>>n>>m;
    vll v(n);
    deque<pair<ll,ll>> v2;
    for(i=0;i<n;i++){
        cin>>v[i];
        if(i>0)v2.pb({v[i]-v[i-1],i-1});
    }
    vll ans(n,0);
    sort(all(v2));
    ll l=0,r=0,x=0;
    for(i=0;i<m;i++){
        ll b;
        cin>>b;
        x+=b;
        l=min(l,x);
        r=max(r,x);
        while(v2.sz && v2[0].fr<=r+abs(l)){
            if(x<0){
                ans[v2[0].sc]+=r;
                ans[v2[0].sc+1]+=v2[0].fr-r;
            }else{
                ans[v2[0].sc+1]+=abs(l);
                ans[v2[0].sc]+=v2[0].fr-abs(l);
            }
            v2.pof;
        }
    }
    for(i=0;i<v2.sz;i++){
        ans[v2[i].sc]+=r;
        ans[v2[i].sc+1]+=abs(l);
    }
    ans[0]+=abs(l);
    ans[n-1]+=r;
    for(i=0;i<n;i++) cout<<ans[i]<<endl;
}

signed main(){
	start();
    ll t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
/*



*/

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:75:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |     for(i=0;i<v2.sz;i++){
      |              ^
Main.cpp:46:10: warning: unused variable 'j' [-Wunused-variable]
   46 |     ll i,j;
      |          ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 18 ms 344 KB Output is correct
21 Correct 17 ms 344 KB Output is correct
22 Correct 19 ms 348 KB Output is correct
23 Correct 18 ms 348 KB Output is correct
24 Correct 20 ms 1116 KB Output is correct
25 Correct 64 ms 8388 KB Output is correct
26 Correct 64 ms 8400 KB Output is correct
27 Correct 78 ms 8216 KB Output is correct
28 Correct 66 ms 8020 KB Output is correct
29 Correct 73 ms 7844 KB Output is correct
30 Correct 67 ms 7508 KB Output is correct
31 Correct 60 ms 7252 KB Output is correct
32 Correct 45 ms 7252 KB Output is correct
33 Correct 7 ms 1116 KB Output is correct
34 Correct 67 ms 8408 KB Output is correct
35 Correct 67 ms 8020 KB Output is correct
36 Correct 64 ms 8408 KB Output is correct
37 Correct 65 ms 8272 KB Output is correct
38 Correct 65 ms 8276 KB Output is correct
39 Correct 66 ms 8272 KB Output is correct
40 Correct 66 ms 8152 KB Output is correct
41 Correct 18 ms 348 KB Output is correct
42 Correct 57 ms 7140 KB Output is correct
43 Correct 54 ms 8276 KB Output is correct
44 Correct 18 ms 348 KB Output is correct
45 Correct 70 ms 8272 KB Output is correct
46 Correct 63 ms 8600 KB Output is correct
47 Correct 63 ms 8444 KB Output is correct
48 Correct 67 ms 8532 KB Output is correct