답안 #638747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638747 2022-09-07T09:04:08 Z jamezzz Sandcastle 2 (JOI22_ho_t5) C++17
9 / 100
7 ms 852 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define sf scanf
#define pf printf
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
#define all(x) x.begin(), x.end()
#define lb(x,v) (lower_bound(all(x),v)-x.begin())
#define ub(x,v) (upper_bound(all(x),v)-x.begin())
#define disc(x) sort(all(x));x.resize(unique(all(x))-x.begin());

#define maxn 50005
#define INF 1023456789

int h,w,a[maxn];

int main(){
	sf("%d%d",&h,&w);
	for(int i=0;i<w;++i){
		sf("%d",&a[i]);
	}
	ll ans=0;int cnt=0;
	for(int i=0;i<w;++i){
		if(i!=0&&a[i-1]>a[i])cnt=0;
		ans+=++cnt;
	}
	cnt=0;
	for(int i=w-1;i>=0;--i){
		if(i!=w-1&&a[i+1]>a[i])cnt=0;
		ans+=++cnt;
	}
	ans-=w;
	pf("%lld\n",ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  sf("%d%d",&h,&w);
      |    ^
Main.cpp:24:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   sf("%d",&a[i]);
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 7 ms 624 KB Output is correct
3 Correct 6 ms 852 KB Output is correct
4 Correct 5 ms 852 KB Output is correct
5 Correct 6 ms 828 KB Output is correct
6 Correct 6 ms 828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -