459B Pashmak and Flowers

这道题给我wa惨了,数组元素范围分明是10^9,int完全够啊,今天改成long long 过了,求解释啊

#include<iostream>
#include<stdio.h>
#include<algorithm>
#define N 200005
using namespace std;
int main(){
    long long n,a[N];
    while(cin>>n){
        for(long long i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        long long lena=1,lenb=1;
        for(long long i=1;i<n;i++)
            if(a[0]==a[i]) lena++;
        for(long long i=n-2;i>=0;i--)
            if(a[n-1]==a[i]) lenb++;
        if(lena==n){
            long long t=0;
            cout<<t<<" "<<n*(n-1)/2<<endl;
        }
        else{
            cout<<a[n-1]-a[0]<<" "<<lenb*lena<<endl;
        }
    }
}

459B Pashmak and Flowers,布布扣,bubuko.com

时间: 2024-12-21 22:30:44

459B Pashmak and Flowers的相关文章

Codeforces Round #261 (Div. 2) 459B. Pashmak and Flowers(数学题,组合)

题目链接:http://codeforces.com/problemset/problem/459/B B. Pashmak and Flowers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak decided to give Parmida a pair of flowers from the garden.

Pashmak and Flowers

Pashmak decided to give Parmida a pair of flowers from the garden. There are nflowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. Sh

Codeforces Round #261 (Div. 2)[ABCDE]

Codeforces Round #261 (Div. 2)[ABCDE] ACM 题目地址:Codeforces Round #261 (Div. 2) A - Pashmak and Garden 题意: 一个正方形,它的边平行于坐标轴,给出这个正方形的两个点,求出另外两个点. 分析: 推断下是否平行X轴或平行Y轴,各种if. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * File: A.cpp * Create Date: 2014-0

Codeforces Round #261 (Div. 2)

A. Pashmak and Garden 题意:已知两个顶点的坐标,如果能推断出另外两个顶点则输出(special judge).如果这两个顶点不是构成正方形的两个顶点, 则输出-1. 水题,1A,不多说. #include<cstdio> #include<iostream> #include<cstring> #include<cmath> using namespace std; int main() { int x1,x2,y1,y2,flag,x

大神刷题表

9月27日 后缀数组:[wikioi3160]最长公共子串 dp:NOIP2001统计单词个数 后缀自动机:[spoj1812]Longest Common Substring II [wikioi3160]最长公共子串 [spoj7258]Lexicographical Substring Search 扫描线+set:[poj2932]Coneology 扫描线+set+树上删边游戏:[FJOI2013]圆形游戏 结论:[bzoj3706][FJ2014集训]反色刷 最小环:[poj1734

New Training Table

      2014_8_15 CodeForces 261 DIV2 A. Pashmak and Garden 简单题   B. Pashmak and Flowers    简单题   C. Pashmak and Buses     好题!k进制的应用   D. Pashmak and Parmida's problem 简单题! 统计+树状数组    E. Pashmak and Graph 简单题!排序+DP                          New Training

Flowers(二分水过。。。)

Flowers Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2579    Accepted Submission(s): 1265 Problem Description As is known to all, the blooming time and duration varies between different kinds

BNUOJ 1038 Flowers(BFS)

Flowers Time Limit: 1000ms Memory Limit: 65535KB 64-bit integer IO format: %lld      Java class name: Main Prev Submit Status Statistics Discuss Next 春天到了,师大的园丁们又开始忙碌起来了. 京师广场上有一块空地,边界围成了一个多边形,内部被划分成一格一格的.园丁们想在这个多边形内的每一格内种植一些花. 现在请你帮忙计算一下一共最多可以种多少花.

Codeforces Round #261 (Div. 2)459A. Pashmak and Garden(数学题)

题目链接:http://codeforces.com/problemset/problem/459/A A. Pashmak and Garden time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak has fallen in love with an attractive girl called Parmida s