Submission #827557

#TimeUsernameProblemLanguageResultExecution timeMemory
827557Anthony_LiuRabbit Carrot (LMIO19_triusis)C++11
100 / 100
25 ms5320 KiB
#include<bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast") //#pragma GCC target("avx2") //#pragma GCC optimization ("unroll-loops") #define f first #define s second #define ll long long #define pb push_back #define pi pair <int,int> #define vi vector <int> #define size(x) (int)(x).size() #define all(x) x.begin(), x.end() void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); if (size(name)) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } int lis(vi &a) { vi dp; for (auto u : a) { int p = upper_bound(all(dp), u) - dp.begin(); if (p == size(dp)) dp.pb(u); else dp[p] = u; } return size(dp); } int N, M; int main() { setIO(); cin >> N >> M; vi poles(N); for (int i = 0; i < N; i++) cin >> poles[i]; vi pos; for (int i = 1; i <= N; i++) { if (i * M >= poles[i - 1]) { pos.pb(i * M - poles[i - 1]); } } cout << N - lis(pos) << endl; return 0; }

Compilation message (stderr)

triusis.cpp: In function 'void setIO(std::string)':
triusis.cpp:17:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   freopen((name + ".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:18:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   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...