Submission #739949

#TimeUsernameProblemLanguageResultExecution timeMemory
739949yuhongFinancial Report (JOI21_financial)C++17
14 / 100
2756 ms1048576 KiB
#include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #define endl '\n' #define ll long long #define pb push_back #define vi vector<int> #define vll vector<long long> #define sz(x) (int)x.size() #define int long long #define all(x) x.begin(),x.end() #define pii pair<int,int> #define piii pair<int,pii> #define rep(i,a,b) for (ll i = a; i<b; i++) #define repo(i,a,b) for (int i = a; i>=b; i--) #define sets(a,b) memset(a, b, sizeof(a)) #define fi first #define se second int dy[8] = {0, 0, 1, -1, 1, -1 , 1, -1}; int dx[8] = {1, -1, 0, 0, 1, -1, -1, 1}; //int dp[100001][100001]; //int arr[100001]; const int MOD = 1e9+7; const int INF = 1e9; const int LOG = 20; const int maxn = 1e5 + 5; void solve(){ int n,d; cin>>n>>d; vi v(n+1); for(int i=0;i<n;i++){ cin>>v[i]; } //subtask 1 bitmasks vector<vi> ans; for(int i =0;i<=(1<<n);i++){ int temp = i; vi t; bool flag = true; int cnt = 0; while(temp>0){ if(temp&1){ t.pb(cnt); } cnt++; temp = (temp>>1); } for(int j = 0;j<sz(t)-1;j++){ if(abs(t[j]-t[j+1])>d){ flag = false; break; } } if(flag){ for(int j = 0;j<sz(t);j++){ t[j] = v[t[j]]; } ans.pb(t); } } int sol = -1; for(auto x : ans){ int cnt = 0; int curmax = -1; for(int i = 0;i<sz(x);i++){ if(x[i]>curmax){ cnt++; curmax = x[i]; } } sol = max(sol,cnt); } cout<<sol<<endl; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int k = 1; while(k--){ solve(); } return 0; }
#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...