Submission #945760

#TimeUsernameProblemLanguageResultExecution timeMemory
945760kokoxuyaFancy Fence (CEOI20_fancyfence)C++14
0 / 100
1 ms856 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int findRect(int height, int width, int inc) { int ans = (height + 1) * height / 2; ans *= width; ans *= inc; return ans; } int incRect(int height, int width) { int ans = height * (height + 1)/2; ans *= ((width + 1) * width/2); return ans; } signed main() { int N; cin >> N; vector<int>heights(N + 1); vector<int>widths(N + 1); for (int a = 1; a <= N; a++) { cin >> heights[a]; } for (int a = 1; a <= N; a++) { cin >> widths[a]; } int ans = 0; vector<vector<pair<int,int>>>rects(N + 1); //height, width for (int curr = 1; curr <= N; curr++) { int at = 0; for (auto prev: rects[curr - 1]) { if (at == heights[curr]) { continue; } ans += (findRect(min(heights[curr], prev.first) - at, prev.second, widths[curr])); rects[curr].push_back({min(heights[curr], prev.first), prev.second + widths[curr]}); at = min(heights[curr], prev.first); } ans += incRect(heights[curr],widths[curr]); if (at != heights[curr]) { rects[curr].push_back({heights[curr],widths[curr]}); } } cout << 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...