| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 141639 | 谢思涵 | 收集雨水 | C++ | Accepted | 100 | 788 MS | 288 KB | 516 | 2024-04-06 09:18:41 |
#include <iostream> using namespace std; int a[100100]; int main() { int n, maxh = -1; cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; maxh = max(maxh, a[i]); } int sum = 0; for(int h = 1; h <= maxh; h++) { int sumh = 0; for(int i = 1; i <= n; i++) { if(a[i] >= h) { for(int j = i + 1; j <= n; j++) { if(a[j] >= h) { sumh += (j - i) - 1; i = j; } } } } sum += sumh; } cout << sum << endl; return 0; }