답안 #594071

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594071 2022-07-12T04:42:21 Z 반딧불(#8432) Sandcastle 2 (JOI22_ho_t5) C++17
9 / 100
10 ms 856 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, m;
int arr[50002];
ll ans;

int main(){
    scanf("%d %d", &n, &n);
    for(int i=1; i<=n; i++) scanf("%d", &arr[i]);
    ans = n;
    for(int i=1; i<n; i++){
        int j = i;
        while(j+2<=n && ((arr[j+1]<arr[j+2]) == (arr[i]<arr[i+1]))) j++;
        ans += ll(j-i+1)*(j-i+2)/2;
        i=j;
    }
    printf("%lld", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d", &n, &n);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:13:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(int i=1; i<=n; i++) scanf("%d", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 10 ms 856 KB Output is correct
4 Correct 6 ms 852 KB Output is correct
5 Correct 6 ms 852 KB Output is correct
6 Correct 8 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -