Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
longlong简单水过。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator