Submission #878033

#TimeUsernameProblemLanguageResultExecution timeMemory
878033frostray8653Snowball (JOI21_ho_t2)C++17
33 / 100
13 ms844 KiB
// #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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...