Submission #1064447

#TimeUsernameProblemLanguageResultExecution timeMemory
1064447YassirSalamaHoliday (IOI14_holiday)C++17
7 / 100
5097 ms1112 KiB
#include"holiday.h" #include<bits/stdc++.h> using namespace std; #define ll long long int arr[21]; bool visited[21]; int n,d; long long int findMaxAttraction(int _n, int start, int _d, int v[]) { ll ans = 0; n=_n; d=_d; for(int i=1;i<(1LL<<n);i++){ int a=1e9; int b=0; ll cost=0; ll s=0; int t=0; vector<int> vv; for(int j=0;j<n;j++){ if((1LL<<j)&i){ a=min(a,j); b=max(b,j); t++; s+=v[j]; vv.push_back(v[j]); } } if(a<=start&&start<=b){ int x=b-a+start-a; int y=b-start+b-a; cost=min(x,y); } if(start<=a&&a<=b){ cost=b-start; } if(a<=b&&b<=start){ cost=start-a; } cost+=t; // cout<<cost<<" : "; // for(auto x:vv){ // cout<<x<<" "; // } // cout<<endl; if(d>=cost){ ans=max(ans,s); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...