Submission #940694

#TimeUsernameProblemLanguageResultExecution timeMemory
940694pakapu3D Histogram (COCI20_histogram)C++17
0 / 110
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n; cin >> n; vector<int> a(n); vector<int> b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } int curr_len = 1; int curr_min_a = a[0]; int curr_min_b = b[0]; int prev_ans = a[0] * b[0]; int ans = a[0] * b[0]; for (int i = 1; i < n; i++) { curr_min_a = min(curr_min_a, a[i]); curr_min_b = min(curr_min_b, b[i]); curr_len++; if (curr_min_a * curr_min_b * curr_len <= a[i] * b[i]) { curr_min_a = a[i]; curr_min_b = b[i]; curr_len = 1; } ans = max(ans, curr_min_a * curr_min_b * curr_len); prev_ans = curr_min_a * curr_min_b * curr_len; } cout << ans << '\n'; return 0; }

Compilation message (stderr)

histogram.cpp: In function 'int main()':
histogram.cpp:22:6: warning: variable 'prev_ans' set but not used [-Wunused-but-set-variable]
   22 |  int prev_ans = a[0] * b[0];
      |      ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...