Submission #676649

# Submission time Handle Problem Language Result Execution time Memory
676649 2022-12-31T15:01:36 Z owoovo Sandcastle 2 (JOI22_ho_t5) C++14
9 / 100
17 ms 880 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int ori[500010];
int main(){
    ll n,m;
    cin>>n>>m;
    if(n!=1){
        cout<<"0\n";
        return 0;
    }
    if(m==1){
        cin>>ori[0];
        cout<<"1\n";
        return 0;
    }
    for(int i=0;i<m;i++){
        cin>>ori[i];
    }
    ll ans=0;
    ll nowc=2;
    for(int i=2;i<m;i++){
        if((ori[i]>ori[i-1])^(ori[i-1]>ori[i-2])){
            ans+=nowc*(nowc-1)/2+nowc-1;
            nowc=2;
        }else{
            nowc++;
        }
    }
    ans+=nowc*(nowc-1)/2+nowc;
    cout<<ans<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 16 ms 832 KB Output is correct
3 Correct 16 ms 804 KB Output is correct
4 Correct 16 ms 852 KB Output is correct
5 Correct 16 ms 808 KB Output is correct
6 Correct 17 ms 880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -