2348: [Baltic 2011]plagiarism time limit:1 Sec Memory limit:256 MB
submit:304 solved:141
[Submit] [Status] DescriptionThe World Programming Competition contestants submit N Program Files
F1, ...,
FN to the evaluation system. The jury wants to rule out all possible plagiarism before the results are formally published. They already have a contrast program that compares two copies of program files and determines if they are too similar. However, the number of program files is quite large, andit will take too much time to compare every two copies (pair, pair) files. On the other hand, many pairs can be directly excluded if the size of the file is too large. more accurately, the jury decided that if each of the two documents (pair,pair), the smaller file volume is smaller than the size of the larger file 90%, that would directly not compare such a pair (pair). So, the contrast program only compares such a pair (
fi,
Fj): i≠j, size (
Fi) ≤size (
Fj) and size (
fi) ≥0.9?size (
Fj). The program calculates how many pairs (pair) files need to be compared. Input Line 1 contains an integer N, which is the total number of program files submitted. Line 2 contains N integers size (
F1), ..., size (
FN), and each integer represents the volume size of the file. Output Line 1 , also the only row, gives an integer that is the number of pairs (pair) of files that need to be compared .
Data Range1≤n≤1001≤size (
Fi) ≤100
in a test point with a score of.1≤n≤2
Sample Input5
1 1 1) 1 1Sample OutputTenThe following:
After sorting two points can be.
Code:
1#include <cstdio>2 3#include <cstdlib>4 5#include <cmath>6 7#include <cstring>8 9#include <algorithm>Ten One#include <iostream> A -#include <vector> - the#include <map> - -#include <Set> - +#include <queue> - +#include <string> A at #defineINF 1000000000 - - #defineMAXN 100000+5 - - #defineMAXM 20000000+5 - in #defineEPS 1e-10 - to #definell Long Long + - #definePA pair<int,int> the * #defineFor0 (i,n) for (int i=0;i<= (n); i++) $ Panax Notoginseng #defineFor1 (i,n) for (int i=1;i<= (n); i++) - the #defineFor2 (i,x,y) for (int i= (x); i<= (y); i++) + A #defineFor3 (i,x,y) for (int i= (x); i>= (y); i--) the + #defineMoD 1000000007 - $ using namespacestd; $ -InlineintRead () - the { - Wuyi intx=0, f=1;CharCh=GetChar (); the - while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} Wu - while(ch>='0'&&ch<='9') {x=Ten*x+ch-'0'; ch=GetChar ();} About $ returnx*F; - - } - intN,A[MAXN]; A + intMain () the - { $ theFreopen ("Input.txt","R", stdin); the theFreopen ("output.txt","W", stdout); the -n=read (); inFor1 (i,n) a[i]=read (); theSort (A +1, a+n+1); ll ans=0; the For1 (i,n) About { the intl=i+1, r=N; the while(l<=R) the { + intMid= (l+r) >>1; - if(Ten*a[i]>=9*a[mid]) l=mid+1;Elser=mid-1; the }Bayians+= (LL) (Ri); the } thecout<<ans<<Endl; - - return 0; the the}
View Code
BZOJ2348: [Baltic 2011]plagiarism