답안 #532129

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532129 2022-03-02T06:34:59 Z Haruto810198 Sandcastle 2 (JOI22_ho_t5) C++17
9 / 100
8 ms 1072 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
#define szof(x) ((int)(x).size())

#define vi vector<int>
#define pii pair<int, int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF = INT_MAX;
const int LNF = INF*INF;
const int MOD = 1000000007;
const int mod = 998244353;
const double eps = 1e-12;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

const int MAX = 50010;

int h, n;
int arr[MAX];
int res;

void solve(){
	int ptr = 1;
	FOR(i, 1, n, 1){
		ptr = max(ptr, i);
		while(ptr < n and arr[ptr] > arr[ptr + 1]) ptr++;
		res += (ptr - i + 1);
		//cerr<<i<<" "<<ptr<<endl;
	}
}

signed main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>h>>n;
	
	FOR(i, 1, n, 1){
		cin>>arr[i];
	}
	
	solve();
	reverse(arr+1, arr+n+1);
	solve();

	res -= n;
	cout<<res<<'\n';
	
	return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 8 ms 972 KB Output is correct
3 Correct 6 ms 968 KB Output is correct
4 Correct 5 ms 972 KB Output is correct
5 Correct 5 ms 1072 KB Output is correct
6 Correct 5 ms 1072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -