Submission #928276

# Submission time Handle Problem Language Result Execution time Memory
928276 2024-02-16T06:49:36 Z pcc Sandcastle 2 (JOI22_ho_t5) C++17
9 / 100
4 ms 924 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
vector<vector<int>> arr;
ll H,W;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>H>>W;
	arr = vector<vector<int>>(H,vector<int>(W));
	ll ans = 0;
	for(auto &i:arr)for(auto &j:i)cin>>j;
	for(int i = 0;i<W;){
		int pr = i;
		int mn = arr[0][i];
		while(pr<W&&arr[0][pr]<=mn)mn = arr[0][pr],pr++;
		ll len = pr-i;
		ans += len*(len+1)>>1;
		i = pr;
	}
	for(int i = W-1;i>=0;){
		int pr = i,mn = arr[0][i];
		while(pr>=0&&arr[0][pr]<=mn)mn = arr[0][pr],pr--;
		ll len = i-pr;
		ans += len*(len-1)>>1;
		i = pr;
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 4 ms 920 KB Output is correct
3 Correct 4 ms 924 KB Output is correct
4 Correct 4 ms 920 KB Output is correct
5 Correct 4 ms 920 KB Output is correct
6 Correct 4 ms 916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -