[codeforces 1313C1] 스카이스크래퍼스(easy version)는 골짜기를 묻고 봉우리를 맞춘다.

1510 단어 codeforces
Codeforces Round #622(Div.2) 시합 인원수 5752
[codeforces 1313C1] 스카이스크래퍼스(easy version)는 골짜기를 묻고 봉우리를 맞춘다.
총목록 상세 정보https://blog.csdn.net/mrcrack/article/details/103564004
온라인 평가 주소https://codeforces.ml/contest/1313/problem/C1
Problem
Lang
Verdict
Time
Memory
C1 - Skyscrapers (easy version)
GNU C++11
Accepted
31 ms
0 KB
시합 때 이 문제 C1의 AC율이 B문제의 2-3배인 것을 발견하였는데, 기본적으로 다음과 같은 알고리즘은 성숙한 알고리즘이라고 볼 수 있다.
시합할 때도 과감하게 B문제를 놓고 C1문제의 코드를 시작한다.
골짜기를 물었더니 봉우리를 맞혔다.
샘플 수동 알고리즘은 다음과 같다.
Input1
5
1 2 3 2 1      
Output1
1 2 3 2 1   3  

Input2
3
10 6 8      6  

    
10 6 6      10            ,     ,int   
6 6 8       6  

Output2
10 6 6      10  


      :          , 
Also there mustn't be integers j and k such that jai

입력한 모든 데이터를 피크로 만들고 새 배열을 처리하며 그에 상응하는 합을 계산합니다. and the total number of floors in all skyscrapers is the maximum possible.가장 큰 합을 고르다.
AC 코드는 다음과 같습니다.
#include 
#define maxn 1010
#define LL long long
LL tot,sum;
int a[maxn],m[maxn],ans[maxn];
int min(int a,int b){
	return a=1;j--)a[j]=min(m[j],a[j+1]),sum+=a[j];//    
		for(j=i+1;j<=n;j++)a[j]=min(m[j],a[j-1]),sum+=a[j];//    
		if(tot

 

좋은 웹페이지 즐겨찾기