; R:=n; last:=i; the whileL Do + begin -mid:= (l+r) >>1; $ ifs[mid]-s[i-1] Then beginLast:=mid; L:=mid+1;End $ Elser:=mid-1; - End; -Ans:=max (ans,last-i+1); the End; - writeln (ans);Wuyi//close (input); the//close (output); - End.View CodeThen a linear scan, ACM called the Ruler method, the machine room big God called the extension of the head contraction tailL +1 after the cycle is due to the beginning of the next continuous interval,
At first thought died of precision ... Half a day to find died in long long ...One or two-point method:#include Second, the ruler of the extraction:#include "Dichotomy", "ruler Method" bzoj2348 [Baltic 2011]plagiarism
I saw the screen software picpick from a small audience and tried to use it. I still don't recommend it from the software perspective, but the several features attached to the software really attract me.
Screen ruler:
I like this. I used it today when I was unable to determine the size of the left column when I added clicki statistics. The 180px test is very accurate.
PS: If you only want a screen ruler
Multi-school questions, put the math problem, but did not want to come out, stupid explosion, before the half-day s[i][j] and, in fact, is a product. In fact, when the game I even log (S[i][j]) +1 is s[i][j] The number of bits have not seen, said to be ashamed.After knowing this, we enumerate the binary number of each bit, because the elements are non-negative, so the sum of the array is non-descending, here used to the ruler, before also heard, shoul
Topic Link: PortalTest instructions: Set F (i,j) to denote the sum of the elements within the interval [i,j], and define sums (i,j) = [Log2 (f (i,j)) +1]* (I+J)Seek Sigma (SUM (i,j)) (1Analysis: log2 (f (i,j)) represents the length of F (i,j) converted to 2, and then we analyze the range of log2 (f (i,j)) +1 for [1,34] then we enumerate the values of log2 (f (i,j)) +1, for example we enumerate its values to K, for a k we find all the satisfyingThe interval of the condition (i,j), the algebraic e
Problem descriptionTo simplify the building process, Xadillax built some template on the ground. The template is a very big wall and the height of each unit may be different.8Mao and Hungar has to choose any part of this wall as their own wall.The part (I, j) means the wall between unit (i) and unit (j) with their heights.What Hungar thinks a beautiful wall is and the height of each unit is unique.Now give you a wall-template, do should tell Hungar so how many ways he can choose to copy his own
A sequence of n positive integers (10 Ruler Acquisition Method Set two pointers, S, T. Maintain the information of an interval, and update the interval information based on the movement of the pointer. Time complexity O (n ). Exercise questions of the same type: Poj 3320 Jessica's reading problem # Include Poj3061 subsequence, ruler acquisition
O (n) to enumerate all segments with a length of K, each violent transfer.
During the transfer, only one number is inserted from the end and one number is deleted from the front.
Calculate the current Max and Min values.
These operations are O (logn) with the Multiset (distinct element is rewritable.
1 #include
[Ruler acquisition method] [Multiset] bzoj1342 [baltic2007] sound mute Problem
Test instructionsIn a sequence of length n, find the shortest length sequence so that it is greater than or equal to s;Ideas:pointer, water problem;AC Code:#include /*#include */using namespacestd;#definefor (i,j,n) for (int i=j;i#defineRiep (n) for (int i=1;i#defineRIOP (n) for (int i=0;i#defineRJEP (n) for (int j=1;j#defineRJOP (n) for (int j=0;j#defineMST (SS,B) memset (ss,b,sizeof (ss));typedefLong Longll;templateclassT>voidRead (tnum) { CharCH;BOOLf=false; for(Ch=getchar (); ch'0'|| Ch>
A Bit FunTime limit:5000/2500 MS (java/others) Memory limit:32768/32768 K (java/others)Problem descriptionthere is n numbers in a array, as A0, A1 ..., an-1, and another number M. We define a function f (i, j) = ai|ai+1|ai+2| ... | Aj. Where "|" is the bit-or operation. (I The problem is really simple:please count the number of the different pairs of (I, J) where F (i, J) Inputthe first line has a number T (T For each test case, first line contains, numbers n and M. (1 Outputfor every case, you
Title Link: Http://codeforces.com/problemset/problem/660/CRuler, each time you encounter 0 of the time to fill a 1, until the completion or out of bounds. Each time a 0 point is recycled from left to right. The recording path is jammed with two pointers, each updated.1#include 2#include 3#include 4#include 5#include 6#include 7#include 8#include 9#include Ten#include One#include A#include -#include -#include the#include -#include Set> -#include -#include + - using namespacestd; + A Con
POJ3320 Jessica ' s Reading problemSet is used to count the number of all non-repeating knowledge points, and map is used to maintain the number of occurrences of each knowledge point on the interval [s,t], which is a good representation of the flexible application of map #include #include#include#include#include#include#include#includeSet>#includestring>#includeusing namespacestd;Const intINF =0x3f3f3f3f; typedefLong Longll;Const intMax_p =1000010;intP;inta[max_p];intMain () {scanf ("%d", q);
A-Fried chicken want to lose weight of stringTime limit:MS Memory Limit:65535KB 64bit IO Format:SubmitStatusPracticenbut 1576DescriptionOnce upon a time, there was a string of long, long strings consisting of n lowercase letters.One day when it was looking in the mirror, he felt too fat, so he wanted to lose weight. When you lose weight, you can constantly remove the first or last character.After it wants to lose weight, for a slim factor m, the slim factor must contain ' a ', ' B ', ' C ' ...
Title: http://poj.org/problem?id=3320Test instructions: Given an array of n elements, find the shortest interval so that the element type within the interval equals the element type of the entire array.Analysis: The beginning of the violent enumeration interval x, and then find the smallest y, so that the interval [x, y] satisfies the condition, X shifted to the X ', now Y ' certainly not on the left of Y. Both map and hash can be used.Map Code:#include Hash code:#include POJ 3320 Jessica ' s Re
Poj3320 (ruler acquisition) and poj3320
N number. The minimum interval overwrites all the different numbers in n number.
Solution:
AC code:
Import java. util. hashMap; import java. util. hashSet; import java. util. map; import java. util. imports; import java. util. set; public class Main {/*** @ param args */static int n; static Set
Jessica‘s text-book. The second line contains P non-negative integers describing what idea each page is about. The first integer is what the first page is about, the second integer is what the second page is about, and so on. You may assume all integers that appear can fit well in the signed 32-bit integer type.
Output
Output one line: the number of pages of the shortest contiguous part of the book which contains all ideals covered in the book.
Sample Input
51 8 8 8 1
Sample output
2
AC cod
Subsequence
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 9050
Accepted: 3604
DescriptionA sequence of n positive integers (InputThe first line is the number of test cases. The program have to read the numbers N and S, separated by a interval, from the first line. The numbers of the sequence is given in the second line of the "test case", separated by intervals. The input would finish with the end of file.OutputThe the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.