Submission #717998

#TimeUsernameProblemLanguageResultExecution timeMemory
717998vinnipuh01Snowball (JOI21_ho_t2)C++17
100 / 100
338 ms23108 KiB
#include <iostream> #include <bits/stdc++.h> #include <cmath> #include <algorithm> #include <vector> #include <deque> #include <set> #include <stack> #include <string> #include <map> #include <queue> #define int long long #define sqrt sqrtl using namespace std; const long long oo = 1000000000000000000; long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos; /* ViHHiPuh (( `'-""``""-'` )) )-__-_.._-__-( / --- (o _ o) --- \ \ .-* ( .0. ) *-. / _'-. ,_ '=' _, .-'_ / `;#'#'# - #'#'#;` \ \_)) -----'#'----- ((_/ # --------- # '# ------- ------ #' /..-'# ------- #'-.\ _\...-\'# -- #'/-.../_ ((____)- '#' -(____)) cout << fixed << setprecision(6) << x; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen ( "sum.in", "r", stdin ) */ int n, m, a[ 200001 ], l, r, x; set <pair<int, int> > st; int an[ 200001 ]; main () { cin >> n >> m; for ( int i = 1; i <= n; i ++ ) { cin >> a[ i ]; if ( i > 1 ) st.insert( { a[ i ] - a[ i - 1 ], i - 1 } ); } while ( m -- ) { cin >> x; num += x; l = min( l, num ); r = max( r, num ); while ( st.size() && st.begin()->first < ( -l ) + r ) { pos = st.begin()->second; if ( num > 0 ) { an[ pos + 1 ] += -l; an[ pos ] += st.begin()->first + l; } else { an[ pos ] += r; an[ pos + 1 ] += st.begin()->first - r; } st.erase( st.begin() ); } } an[ 1 ] += -l; an[ n ] += r; while ( st.size() ) { pos = st.begin()->second; an[ pos ] += r; an[ pos + 1 ] += ( -l ); st.erase( st.begin() ); } for ( int i = 1; i <= n; i ++ ) cout << an[ i ] << "\n"; } /* */

Compilation message (stderr)

Main.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...