Submission #1232995

#TimeUsernameProblemLanguageResultExecution timeMemory
1232995adadRabbit Carrot (LMIO19_triusis)C++20
100 / 100
16 ms5568 KiB
#include <bits/stdc++.h> #define TASK "" #define MASK(i) (1<<(i)) #define BIT(x, i) (((x)>>(i))&1) #define int long long #define fi first #define se second using namespace std; const long long INF = 1e17, MOD = 1e9 + 7, MAX = 2e5 + 5; int n, M, h[MAX], tmp[MAX]; vector <int> lis; 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(NULL); cin >> n >> M; for(int i = 1; i <= n; i ++) cin >> h[i]; int len = 0; for(int i = 1; i <= n; i ++) { if (M * i - h[i] >= 0) { tmp[len] = M * i - h[i]; len ++; } } for(int i = 0; i < len; i ++) { auto pos = upper_bound(lis.begin(), lis.end(), tmp[i]); if (pos == lis.end()) lis.push_back(tmp[i]); else *pos = tmp[i]; } cout << n - lis.size(); }

Compilation message (stderr)

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