BZ's water problem ...
What is the scientific name of the question "two pointers"? It's a linear sweep. I'm going to 、、、.
POPOQQQ called "on the efficient and rational use of sequencing algorithms and the ability to remember the use of sorting algorithms" 2333
1 /**************************************************************2 problem:23483 User:rausen4 language:c++5 result:accepted6 time:128 Ms7 memory:1196 KB8 ****************************************************************/9 Ten#include <cstdio> One#include <algorithm> A - using namespacestd; -typedefLong Longll; thetypedefDoubleLF; - Const intN =100005; - ConstLF EPS = 1e-8; - + intN, A[n]; - ll ans; + AInlineintRead () { at intx =0, SGN =1; - CharCH =GetChar (); - while(Ch <'0'||'9'<ch) { - if(ch = ='-') SGN =-1; -CH =GetChar (); - } in while('0'<= CH && Ch <='9') { -x = x *Ten+ CH-'0'; toCH =GetChar (); + } - returnSGN *x; the } * $ intMain () {Panax Notoginseng intI, J; -n =read (); the for(i =1; I <= N; ++i) +A[i] =read (); ASort (A +1, A + n +1); the for(i = j =1; I <= N; ++i) { + while(A[j] + EPS < (LF) a[i] *0.9) -++J; $Ans + = i-J; $ } -printf"%lld\n", ans); - return 0; the}
View Code
BZOJ2348 [Baltic 2011]plagiarism