Submission #1276191

#TimeUsernameProblemLanguageResultExecution timeMemory
1276191Bui_Quoc_CuongFinancial Report (JOI21_financial)C++20
0 / 100
4094 ms33708 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=a;i<=(int)b;i++) #define FORD(i,a,b) for(int i=a;i>=(int)b;i--) #define ll long long #define fi first #define se second #define pb push_back #define all(a) a.begin(),a.end() #define BIT(mask,i) ((mask>>(i))&1) #define MASK(a) (1LL<((a))) #define uni(v) sort(all(v)); v.resize(unique(all(v)) - v.begin()) #define pii pair <int, int> #define vi vector <int> #define vl vector <ll> template <class A,class B> bool maximize(A &a, const B b) { if(a < b){ a = b; return 1;} return 0; } template <class A,class B> bool minimize(A &a, const B b) { if(a > b){ a = b; return 1;} return 0; } const int maxn = 3e5 + 5; int n, d; int a[maxn], dp[maxn]; vector <int> open[maxn]; multiset <pair <int, int>> se[maxn]; int st[4 * maxn]; void update(int pos, int val) { int id = 1, l = 1, r = n; while(l < r) { int mid = (l + r) >> 1; if(pos <= mid) id = id << 1, r = mid; else id = id << 1 | 1, l = mid + 1; } st[id] = val; while(id > 1) { id >>= 1; st[id] = max(st[id << 1], st[id << 1 | 1]); } } int get(int id, int l, int r, int u, int v) { if(l > v || r < u) return 0; if(l >= u && r <= v) return st[id]; int mid = (l + r) >> 1; return max(get(id << 1, l, mid, u, v), get(id << 1 | 1, mid + 1, r, u, v)); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define kieuoanh "kieuoanh" if(fopen(kieuoanh".inp","r")) { freopen(kieuoanh".inp","r",stdin); freopen(kieuoanh".out","w",stdout); } cin >> n >> d; for(int i = 1; i <= n; i++) cin >> a[i]; vi values; for(int i = 1; i <= n; i++) values.pb(a[i]); uni(values); for(int i = 1; i <= n; i++) a[i] = upper_bound(all(values), a[i]) - values.begin(); for(int i = 1; i <= n; i++) open[i + d + 1].push_back(i); for(int i = 1; i <= n; i++) { int cur = 0; dp[i] = 1; for(int j = i - 1; j >= 1; j--) { if(a[j] > a[i]) cur++; else cur = 0; if(cur >= d) break; if(a[j] < a[i]) maximize(dp[i], dp[j] + 1); } } int ans = 0; for(int i = max(1, n - d); i <= n; i++) maximize(ans, dp[i]); cout << ans; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen(kieuoanh".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(kieuoanh".out","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...