Submission #878033

# Submission time Handle Problem Language Result Execution time Memory
878033 2023-11-24T03:04:24 Z frostray8653 Snowball (JOI21_ho_t2) C++17
33 / 100
13 ms 844 KB
// #pragma GCC optimize("Ofast,unroll-loops,O3")
#include <bits/stdc++.h>
#define int long long
// #define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a, I = b; i <= b; i++)
using namespace std;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) {cout << a << " "; dbg(b...);}
void ent() {cout << "\n";}

const int mod = 998244353;
// const int mod = 1e9 + 7;
// const int INF = 2e9;
const int INF = 1e18;

/// ------- Initialization End -------

const int N = 2005;
int a[N];
int dx[N];

signed main() {
    IO;
    int n, m;
    cin >> n >> m;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, m) cin >> dx[i];

    a[0] = -INF;
    a[n + 1] = INF;
    FOR(i, 1, n) {
        int l_lim = -INF, r_lim = INF;
        int l = a[i], r = a[i];
        int now = a[i], bef = a[i - 1], nxt = a[i + 1];
        FOR(j, 1, m) {
            if (dx[j] > 0) {
                r_lim = min(r_lim, nxt);
                nxt += dx[j];
                r = max(r, min(r_lim, now + dx[j]));
                now += dx[j];
                bef += dx[j];
                l_lim = max(l_lim, bef);
            } else {
                l_lim = max(l_lim, bef);
                bef += dx[j];
                l = min(l, max(l_lim, now + dx[j]));
                now += dx[j];
                nxt += dx[j];
                r_lim = min(r_lim, nxt);
            }
        }
        cout << r - l << "\n";
    }
/*
4 3
-2 3 5 8
2
-4
7
*/
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:8:38: warning: unused variable 'I' [-Wunused-variable]
    8 | #define FOR(i, a, b) for (int i = a, I = b; i <= b; i++)
      |                                      ^
Main.cpp:30:5: note: in expansion of macro 'FOR'
   30 |     FOR(i, 1, n) cin >> a[i];
      |     ^~~
Main.cpp:8:38: warning: unused variable 'I' [-Wunused-variable]
    8 | #define FOR(i, a, b) for (int i = a, I = b; i <= b; i++)
      |                                      ^
Main.cpp:31:5: note: in expansion of macro 'FOR'
   31 |     FOR(i, 1, m) cin >> dx[i];
      |     ^~~
Main.cpp:8:38: warning: unused variable 'I' [-Wunused-variable]
    8 | #define FOR(i, a, b) for (int i = a, I = b; i <= b; i++)
      |                                      ^
Main.cpp:39:9: note: in expansion of macro 'FOR'
   39 |         FOR(j, 1, m) {
      |         ^~~
Main.cpp:8:38: warning: unused variable 'I' [-Wunused-variable]
    8 | #define FOR(i, a, b) for (int i = a, I = b; i <= b; i++)
      |                                      ^
Main.cpp:35:5: note: in expansion of macro 'FOR'
   35 |     FOR(i, 1, n) {
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 10 ms 344 KB Output is correct
5 Correct 11 ms 348 KB Output is correct
6 Correct 10 ms 540 KB Output is correct
7 Correct 11 ms 348 KB Output is correct
8 Correct 10 ms 528 KB Output is correct
9 Correct 11 ms 348 KB Output is correct
10 Correct 13 ms 500 KB Output is correct
11 Correct 10 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 460 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 11 ms 472 KB Output is correct
16 Correct 11 ms 844 KB Output is correct
17 Correct 10 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 10 ms 344 KB Output is correct
5 Correct 11 ms 348 KB Output is correct
6 Correct 10 ms 540 KB Output is correct
7 Correct 11 ms 348 KB Output is correct
8 Correct 10 ms 528 KB Output is correct
9 Correct 11 ms 348 KB Output is correct
10 Correct 13 ms 500 KB Output is correct
11 Correct 10 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 460 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 11 ms 472 KB Output is correct
16 Correct 11 ms 844 KB Output is correct
17 Correct 10 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 7 ms 348 KB Output is correct
20 Runtime error 1 ms 600 KB Execution killed with signal 11
21 Halted 0 ms 0 KB -