Submission #886600

#TimeUsernameProblemLanguageResultExecution timeMemory
886600dubabubaSandcastle 2 (JOI22_ho_t5)C++14
0 / 100
0 ms348 KiB
#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 (stderr)

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 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...