Submission #1059261

#TimeUsernameProblemLanguageResultExecution timeMemory
1059261SN0WM4NFinancial Report (JOI21_financial)C++14
0 / 100
542 ms1048576 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define sort undefined_function // To use stable_sort instead sort #define bpc __builtin_popcount #define ull unsigned long long #define ld double #define ll long long #define mp make_pair #define F first #define S second #pragma GCC optimize("O3") #ifdef LOCAL #include "debug.h" #else #define dbg(...) 0 #endif using namespace __gnu_pbds; using namespace std; typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> Tree; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll INF = 9223372036854775807LL; const ll inf = 2147483647; const ll MOD = 998244353; //[998244353, 1e9 + 7, 1e9 + 13] const ld PI = acos(-1); const ll NROOT = 300; ll binpow(ll a, ll b, ll _MOD = -1) { if (_MOD == -1) _MOD = MOD; ll res = 1; for (; b; b /= 2, a *= a, a %= _MOD) if (b & 1) res *= a, res %= _MOD; return res; } void set_IO(string s) { #ifndef LOCAL string in = s + ".in"; string out = s + ".out"; freopen(in.c_str(), "r", stdin); freopen(out.c_str(), "w", stdout); #endif } bool dataOverflow(ll a, ll b) {return (log10(a) + log10(b) >= 18);} ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} ll lcm(ll a, ll b) {return a * b / gcd(a, b);} ll ceil(ll a, ll b) {return (a + b - 1) / b;} class ST{ private: int n; vector<ll> st; void update(int nod, int l, int r, int pos, ll val) { if (l == r) { st[nod] += val; return; } int mid = (l + r) >> 1; if (pos <= mid) update(nod << 1, l, mid, pos, val); else update((nod << 1) | 1, mid + 1, r, pos, val); st[nod] = max(st[nod << 1], st[(nod << 1) | 1]); } ll query(int nod, int l, int r, int L, int R) { if (r < L || R < l) return 0; if (L <= l && r <= R) return st[nod]; int mid = (l + r) >> 1; ll q1 = query(nod << 1, l, mid, L, R); ll q2 = query((nod << 1) | 1, mid + 1, r, L, R); return max(q1, q2); } public: ST(int _n) { n = _n; st.resize(4 * n); } void update(int pos, ll val) { update(1, 1, n, pos, val); } ll query(int L, int R) { if (R < L) return 0; return query(1, 1, n, L, R); } void debug() { dbg(st); } }; int n, d; vector<int> v; vector<vector<ll>> memo; ll dp(int i, int last) { if (i > n) return 0; if (memo[i][last] != -1) return memo[i][last]; ll ans = 0; for (int j = 1; j <= d && i + j <= n + 1; j ++) ans = max(ans, dp(i + j, max(v[i], last)) + (last < v[i] ? 1 : 0)); return memo[i][last] = ans; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> d; set<int> s; v.resize(n + 1); memo.resize(n + 1, vector<ll> (n + 10, -1)); for (int i = 1; i <= n; i ++) { cin >> v[i]; s.insert(v[i]); } int index = 0; map<int, int> ID; for (auto &x : s) ID[x] = ++index; for (int i = 1; i <= n; i ++) v[i] = ID[v[i]]; dbg(v); cout << dp(1, 0) << "\n"; return 0; }

Compilation message (stderr)

Main.cpp: In member function 'void ST::debug()':
Main.cpp:18:26: warning: statement has no effect [-Wunused-value]
   18 |         #define dbg(...) 0
      |                          ^
Main.cpp:105:17: note: in expansion of macro 'dbg'
  105 |                 dbg(st);
      |                 ^~~
Main.cpp: In function 'int32_t main()':
Main.cpp:18:26: warning: statement has no effect [-Wunused-value]
   18 |         #define dbg(...) 0
      |                          ^
Main.cpp:151:9: note: in expansion of macro 'dbg'
  151 |         dbg(v);
      |         ^~~
Main.cpp: In function 'void set_IO(std::string)':
Main.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         freopen(in.c_str(),  "r",  stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen(out.c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...