Submission #928276

#TimeUsernameProblemLanguageResultExecution timeMemory
928276pccSandcastle 2 (JOI22_ho_t5)C++17
9 / 100
4 ms924 KiB
#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 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...