Submission #1089218

#TimeUsernameProblemLanguageResultExecution timeMemory
1089218vjudge1Financial Report (JOI21_financial)C++17
0 / 100
28 ms6868 KiB
#include <bits/stdc++.h> using namespace std; #define ff(i, a, b) for(auto i=(a); i<=(b); ++i) #define ffr(i, b, a) for(auto i=(b); i>=(a); --i) #define nl "\n" #define ss " " #define pb push_back #define ppb pop_back() #define pf push_front #define ppf pop_front() #define fi first #define se second #define sz(s) (int)s.size() #define ms(a,x) memset(a, x, sizeof (a)) #define re exit(0) typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pair<int, int> > vpii; typedef vector<pair<ll, ll> > vpll; const ll mod=1e9+7, maxn=1e6+5, inf=1e18; void rf(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen("o.inp","r")){ freopen("o.inp","r",stdin); freopen("o.out","w",stdout); } } int n, d, a[maxn]; int f[maxn]; void compress() { vi v; ff(i, 1, n) v.pb(a[i]); sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end() ), v.end()); ff(i, 1, n) { a[i]=lower_bound(v.begin(), v.end(), a[i])-v.begin()+1; } } bool checksub1() { return n<=7000; } void sub1() { int ans=0; ff(i, 1, n) f[i]=1; ff(i, 1, n) { int id=i; ffr(j, i, 1) { if(id-j>d) break; if(a[i]>a[j]) f[i]=max(f[i], f[j]+1); //if(a[i]>=a[j]) id=j; } ans=max(ans, f[i]); } cout<<ans; } int main() { rf(); cin>>n>>d; ff(i, 1, n) cin>>a[i]; compress(); if(checksub1()) return sub1(), 0; re; }

Compilation message (stderr)

Main.cpp: In function 'void rf()':
Main.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen("o.inp","r",stdin); freopen("o.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:34:44: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen("o.inp","r",stdin); freopen("o.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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...