Submission #791374

#TimeUsernameProblemLanguageResultExecution timeMemory
791374otariusExam (eJOI20_exam)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <cstring> #include <queue> #include <map> #include <cmath> #include <iomanip> using namespace std; #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair <int, int> #define ull unsigned long long // #define int long long // #define int unsigned long long const ll inf = 1e9 + 7; const ll weirdMod = 998244353; map<int, int> mp; int rnk = 0; int pref[5001][10000], dp[5001]; void solve() { int n; cin >> n; if (n > 5000) { int a[n + 1], b[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; int mx = -1, l = 1, ans = 0; for (int i = 1; i < n; i++) { if (max(mx, arr[i]) > b[1]) { if (mx == b[1]) ans += (i - l); mx = -1; l = i + 1; } else mx = max(mx, arr[i]); } cout << ans; return; } set<int> st; int a[n + 1], b[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; st.insert(a[i]); } for (int i = 1; i <= n; i++) { cin >> b[i]; st.insert(b[i]); } for (int v : st) mp[v] = rnk++; for (int i = 1; i <= n; i++) { a[i] = mp[a[i]]; b[i] = mp[b[i]]; for (int j = 0; j < 10000; j++) { pref[i][j] = pref[i - 1][j]; } pref[i][b[i]]++; } for (int j = 1; j <= n; j++) { int mx = -1; for (int i = j; i >= 1; i--) { mx = max(mx, a[i]); dp[j] = max(dp[j], dp[i - 1] + pref[j][mx] - pref[i - 1][mx]); } } int mx = 0; for (int i = 1; i <= n; i++) cout << dp[i] << ' '; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); cout << '\n'; } return 0; }

Compilation message (stderr)

exam.cpp: In function 'void solve()':
exam.cpp:39:25: error: 'arr' was not declared in this scope
   39 |             if (max(mx, arr[i]) > b[1]) {
      |                         ^~~
exam.cpp:40:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   40 |                 if (mx == b[1]) ans += (i - l); mx = -1; l = i + 1;
      |                 ^~
exam.cpp:40:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   40 |                 if (mx == b[1]) ans += (i - l); mx = -1; l = i + 1;
      |                                                 ^~
exam.cpp:63:11: warning: unused variable 'mx' [-Wunused-variable]
   63 |     } int mx = 0;
      |           ^~