# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
886541 | 2023-12-12T09:51:16 Z | dubabuba | Sandcastle 2 (JOI22_ho_t5) | C++14 | 12 ms | 584 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; } cout << ans + m << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 12 ms | 584 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 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 | 1 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 | 1 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 | 1 ms | 348 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |