{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003chtml\u003e\n \u003chead\u003e\u003c/head\u003e\n \u003cbody\u003e\n \u003cdiv id\u003d\"problem-body\"\u003e \n \u003cp\u003eGiven a tree with N (\u003cem\u003eN\u003c/em\u003e \u0026lt;\u003d 100000) nodes. Each node has a interger value x\u003csub\u003ei\u003c/sub\u003e (\u003cem\u003e|x\u003csub\u003ei\u003c/sub\u003e|\u003c/em\u003e \u0026lt;\u003d 10000).\u003c/p\u003e \n \u003cp\u003eYou have to apply Q (\u003cem\u003eQ\u003c/em\u003e \u0026lt;\u003d 100000) operations:\u003c/p\u003e \n \u003cp\u003e1. \u003cem\u003e1 a b \u003c/em\u003e: answer the maximum contiguous sum (maybe empty,will always larger than or equal to 0 )\u0026nbsp;from the path \u003cem\u003ea-\u0026gt;b\u003c/em\u003e ( inclusive ).\u003c/p\u003e \n \u003cp\u003e2. \u003cem\u003e2 a b c\u003c/em\u003e : change all value in the path \u003cem\u003ea-\u0026gt;b\u003c/em\u003e ( inclusive ) to \u003cem\u003ec\u003c/em\u003e. (\u003cem\u003e|c|\u003c/em\u003e \u0026lt;\u003d 10000)\u003c/p\u003e \n \n \u003c/div\u003e\n \u003c/body\u003e\n\u003c/html\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003chtml\u003e\n\u003chead\u003e\u003c/head\u003e\n\u003cbody\u003e\n\u003cp\u003efirst line consists one interger N.\u003c/p\u003e \n \u003cp\u003enext line consists N intergers x\u003csub\u003ei\u003c/sub\u003e.\u003c/p\u003e \n \u003cp\u003enext N-1 line , each consists two interger u,v , means that node u and node v are connected\u003c/p\u003e \n \u003cp\u003enext line consists 1 interger Q.\u003c/p\u003e \n \u003cp\u003enext Q line : \u003cem\u003e1 a b \u003c/em\u003eor \u003cem\u003e2 a b c\u003c/em\u003e .\u003c/p\u003e \n\u003c/body\u003e\n\u003c/html\u003e\n "}},{"title":"Output","value":{"format":"HTML","content":"\n\u003chtml\u003e\n\u003chead\u003e\u003c/head\u003e\n\u003cbody\u003e\n \u003cp\u003eFor each query, output one line the maximum contiguous sum.\u003c/p\u003e \n\u003c/body\u003e\n\u003c/html\u003e\n "}},{"title":"Example","value":{"format":"HTML","content":"\n\u003chtml\u003e\n\u003chead\u003e\u003c/head\u003e\n\u003cbody\u003e \n\u003cpre\u003e\u003cstrong\u003eInput:\u003c/strong\u003e\n5\n-3 -2 1 2 3\n1 2\n2 3\n1 4\n4 5\n3\n1 2 5\n2 3 4 2\n1 2 5\n\n\u003cstrong\u003eOutput:\u003c/strong\u003e\n5\n9\u003c/pre\u003e \n\u003c/body\u003e\n\u003c/html\u003e"}}]}