Submission #1304120

#TimeUsernameProblemLanguageResultExecution timeMemory
1304120dex111222333444555Rabbit Carrot (LMIO19_triusis)C++20
100 / 100
23 ms2364 KiB
#include <bits/stdc++.h> #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define ii pair<int, int> #define fi first #define se second #define all(v) begin(v), end(v) #define siz(v) (int)(v).size() using namespace std; const int MAXN = 2e5 + 4, mod = 1e9 + 7, MAXB = 20; template<class X, class Y> bool minimize(X &x, const Y &y){return x > y ? x = y, 1: 0;} template<class X, class Y> bool maximize(X &x, const Y &y){return x < y ? x = y, 1: 0;} void add(int &a, const int &b){ a += b; if (a >= mod) a -= mod; } void sub(int &a, const int &b){ a -= b; if (a < 0) a += mod; } int mul(const int &a, const int &b){ return 1LL * a * 1LL * b % mod; } int numHeight, height[MAXN], change; bool mark[MAXN]; void input(){ cin >> numHeight >> change; for(int i = 1; i <= numHeight; i++) cin >> height[i]; } void solve(){ vector<int> lis; for(int i = numHeight; i >= 1; i--){ vector<int>::iterator it = upper_bound(all(lis), height[i] - i * change); if (it == end(lis)) lis.push_back(height[i] - i * change); else *it = height[i] - i * change; } cout << numHeight - (upper_bound(all(lis), 0) - begin(lis)) << '\n'; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "test" if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } input(); solve(); }

Compilation message (stderr)

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