Submission #886600

# Submission time Handle Problem Language Result Execution time Memory
886600 2023-12-12T11:48:30 Z dubabuba Sandcastle 2 (JOI22_ho_t5) C++14
0 / 100
0 ms 348 KB
#include <iostream>
#include <vector>
using namespace std;

const int mxn = 1e5 + 10;
int n, m, a[mxn];

int main() {
	cin >> n >> m;
	if(n > 1) return 1;
	for(int i = 0; i < m; i++)
		cin >> a[i];

	vector<int> sus = {0};
	for(int i = 1; i < m - 1; i++) {
		if(a[i] > a[i - 1] && a[i] > a[i + 1]) sus.push_back(i);
		if(a[i] < a[i - 1] && a[i] < a[i + 1]) sus.push_back(i);
	}
	sus.push_back(m - 1);

	int ans = 0;
	for(int i = 1; i < sus.size(); i++) {
		int l = sus[i - 1];
		int r = sus[i];
		ans += (r - l + 1) * (r - l + 2) / 2;
	}
	cout << ans - sus.size() << '\n';
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i = 1; i < sus.size(); i++) {
      |                 ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -