# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638875 | Pietra | Financial Report (JOI21_financial) | C++14 | 303 ms | 2632 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// n valores
// qr escolher m p apresentar - a dif de 2 adjs n pode ser maior que d
// o ultimo a ser mostrado é pm = n (o ultimo cara smp aparece)
// score é o n° vzs q o at eh maior que o pref dele + 1
#include<bits/stdc++.h>
#define int long long
using namespace std ;
// qual o 1o maior p cada cara - esquerda
const int inf = 1e13 ;
const int maxn = 3e5 + 5 ;
int n, mx[maxn], d, v[maxn], esq[maxn] ;
int32_t main(){
cin >> n >> d ;
for(int i = 1 ; i <= n ; i++) cin >> v[i] ;
// esq[1] = 0 ; v[0] = inf ;
// for(int i = 2 ; i <= n ; i++){
// esq[i] = i-1 ;
// while(v[esq[i]] < v[i]) esq[i] = esq[esq[i]] ;
// }
int ans = 0 ;
int tryy = (1<<7) + (1<<6) + (1<<5) + (1<<4);
for(int mask = 0 ; mask < (1<<(n+1)) ; mask++){
if(mask&(1<<0)) continue ;
vector<int> vec ;
// cout << mask << "\n" ;
for(int i = 1 ; i < n + 1 ; i++){
if(mask&(1<<i)) vec.push_back(i) ;
}
bool ok = 1 ;
for(int i = 1 ; i < vec.size() ; i++) if(vec[i] - vec[i-1] > d) ok = 0 ;
if(!ok) continue ;
for(int i = 0 ; i < vec.size() ; i++){
int fmx = -1 ;
for(int j = i - 1 ; j >= 0 ; j--){
if(v[vec[j]] >= v[vec[i]]){fmx = j ; break ;}
}
esq[i] = fmx ;
}
int sm = 0 ;
for(int i = 0 ; i < vec.size() ; i++) sm += (esq[i]==-1) ;
// for(auto a : vec) cout << a << " " ;
// cout << "\n" ;
// for(int i = 0 ; i < vec.size() ; i++) cout << esq[i] << " " ;
// cout << "\n" ;
// cout << sm << "\n" ;
ans = max(ans, sm) ;
}
cout << ans << "\n" ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |