Submission #961976

#TimeUsernameProblemLanguageResultExecution timeMemory
961976Mike_VuLightning Conductor (POI11_pio)C++14
100 / 100
740 ms17936 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dou; #define pii pair<int, int> #define pb push_back #define fi first #define se second //const ll mod = 1e9+7; bool maximize(ll &x, ll y ){ if (x < y) {x = y; return true;}; return false; } bool minimize(ll &x, ll y){ if (x > y) {x = y; return true;} return false; } //void add(ll &x, ll y ){ // x += y; // if (x >= mod) x -= mod; //} //void sub(ll &x, ll y) { // x -= y; // if (x < 0) x += mod; //} const int maxn = 5e5+5; int n; ll a[maxn], ans[maxn] = {0}; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } ll temp = 0; for (int i = 1; i <= n; i++) { for (int k = 1; i- (k-1)*(k-1)-1 > 0; k++) { maximize(temp, a[i-(k-1)*(k-1)-1]+k); } maximize(ans[i], temp); } temp = 0; for (int i = n; i > 0; i-- ){ for (int k = 1; i+ (k-1)*(k-1)+1 <= n; k++) { maximize(temp, a[i+(k-1)*(k-1)+1]+k); } maximize(ans[i], temp); } for (int i= 1; i <= n; i++) { cout << max(0LL, ans[i]-a[i]) << "\n"; } }
#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...
#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...