Submission #780053

#TimeUsernameProblemLanguageResultExecution timeMemory
780053fatemetmhr휴가 (IOI14_holiday)C++17
7 / 100
5070 ms1020 KiB
// ~ Be Name Khoda ~ // #include"holiday.h" #include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 5e5 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const int mod = 1e9 + 7; const ll inf = 1e18; vector <int> av; int opt[maxn5]; long long int findMaxAttraction(int n, int start, int d, int attraction[]){ if(d == 0) return 0; ll ret = 0; for(int l = 0; l < n; l++){ av.clear(); opt[l] = -1; ll best = -1; for(int r = l; r < n; r++){ av.pb(attraction[r]); sort(all(av)); reverse(all(av)); int rem = min(abs(l - start), abs(r - start)) + r - l; rem = d - rem; //cout << "hey " << l << ' ' << r << ' ' << rem << endl; if(rem < 0) break; ll sum = 0; for(int i = 0; i < min(rem, int(av.size())); i++) sum += av[i]; if(sum > best){ best = sum; opt[l] = r; } } if(l && opt[l] != -1 && opt[l - 1] != -1 && opt[l] < opt[l - 1]){ //cout << l << ' ' << opt[l] << ' ' << opt[l - 1] << endl; return -1; } ret = max(ret, best); } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...