Submission #1250545

#TimeUsernameProblemLanguageResultExecution timeMemory
1250545quangminh412Financial Report (JOI21_financial)C++20
48 / 100
4094 ms2632 KiB
/* Ben Watson Handle codeforces : quangminh98 Current Theme: Transformers !!!! */ #include <bits/stdc++.h> using namespace std; #define ll long long const string name = "test"; void solve(); signed main() { if (fopen((name + ".inp").c_str(), "r")) { freopen((name + ".inp").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; } // main program const int maxn = 3e5 + 1; int n, d; int a[maxn], dp[maxn], R[maxn]; void solve() { cin >> n >> d; for (int i = 1; i <= n; i++) { cin >> a[i]; R[i] = n; } for (int i = 1; i <= n; i++) { int cur = 0; for (int j = i + 1; j <= n; j++) if (a[j] > a[i]) { cur++; if (cur == d) { R[i] = j; break; } } else cur = 0; } int res = 0; for (int i = n; i > 0; i--) { dp[i] = 1; for (int j = i + 1; j <= R[i]; j++) if (a[j] > a[i]) dp[i] = max(dp[i], dp[j] + 1); res = max(res, dp[i]); } cout << res << '\n'; }

Compilation message (stderr)

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