Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

longlong简单水过。。

Posted by wenbao at 2017-02-22 16:32:57 on Problem 3250
#include <stdio.h>
#include <iostream>
int s[80003];
int main(){
	int n, x, num = 0;
	long long sum = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &x);
		while(num > 0 && s[num] <= x) --num; //计算每头牛被看到的次数
		sum += num;
		s[++num] = x;
	}
	printf("%lld\n", sum);
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator