Submission #1021951

#TimeUsernameProblemLanguageResultExecution timeMemory
1021951vjudge1Aliens (IOI16_aliens)C++17
4 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 4e3 + 100; int a[maxn]; int b[maxn]; int c[maxn]; int pref[maxn]; int suf[maxn]; ll dp[maxn][maxn]; int get(int i, int j){ ll x = max(0, (- i + a[i] + j + a[j]) / 2); return x * x; } long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c){ for(int i = 0; i < n; i++){ r[i]++; c[i]++; int x = r[i] + c[i] - 1; a[x] = max(a[x], abs(r[i] - c[i]) + 1); } vector<int> v; for(int i = 1; i < m * 2; i++){ pref[i] = max(pref[i-1] - 1, a[i]); } for(int i = m * 2 - 1; i > 0; i--){ suf[i] = max(suf[i+1] - 1, a[i]); } ll ans = 0; for(int i = 1; i < m * 2; i++){ if(max(pref[i-1], suf[i+1]) <= a[i] && a[i]){ ans += get(i, i); if(v.size()) ans -= get(i, v.back()); v.push_back(i); } } return ans; // for(int i = 0; i <= v.size(); i++){ // fill(dp[i], dp[i] + v.size(), (ll)1e18); // } }
#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...