Submission #676738

#TimeUsernameProblemLanguageResultExecution timeMemory
676738asteilindRabbit Carrot (LMIO19_triusis)C++17
0 / 100
0 ms212 KiB
#include <iostream> #include <vector> #include <queue> #include <string> #include <stack> #include <unordered_map> #include <map> #include <unordered_set> #include <cmath> #include <algorithm> #include <sstream> #include <set> #include <numeric> #include <bitset> #include <climits> #define forn(i, n) for (int i = 0; i < int(n); i++) #define ll long long #define MOD 1000000007 using namespace std; void setIO(string name = "") { // name is nonempty for USACO file I/O ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output if(name.length()){ freopen((name+".in").c_str(), "r", stdin); // see Input & Output freopen((name+".out").c_str(), "w", stdout); } } void solve() { int n; cin >> n; ll ju; cin >> ju; vector<ll> poles(n); vector<int> dp(n); forn(i,n) { cin >> poles[i]; dp[i] = 1; } int maxv = 1; for (int i=0 ; n>i ; i++) { for (int j=0 ; i>j ; j++) { if (poles[j] >= poles[i] || poles[i]-poles[j] <= ju) { dp[i] = max(dp[i],dp[j]+1); maxv = max(dp[i],maxv); } } } cout << maxv << endl; } int main() { setIO(); solve(); }

Compilation message (stderr)

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