Submission #1156715

#TimeUsernameProblemLanguageResultExecution timeMemory
1156715eudhsyfRabbit Carrot (LMIO19_triusis)C++20
100 / 100
18 ms4936 KiB
/* Author : */ #include <bits/stdc++.h> using namespace std; typedef long long ll; #define fi first #define se second #define pii pair<int, int> #define pb push_back #define eb emplace_back #define task "file" const int nmax = 1e6 + 5; int n, dp[nmax], m, a[nmax]; signed main() { if (fopen(task ".inp", "r")) { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] = i * m - a[i]; } memset(dp, 0x3f, sizeof(dp)); dp[0] = 0; int d = 0; for (int i = 1; i <= n; i++) { if (a[i] >= 0) { int l = 1, r = d, id = 0; while (l <= r) { int mid = l + r >> 1; if (dp[mid] <= a[i]) { id = mid, l = mid + 1; } else r = mid - 1; } if (id == d) d++; dp[id + 1] = a[i]; } } cout << n - d; return 0; }

Compilation message (stderr)

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