Rokua-Chinese results [prize] Rokua May Month: The three great artifacts of KKKSC03

Source: Internet
Author: User

Topic Background Background
The Chinese exam is over, and the results are still in question.
Title Description Description
Chinese teachers always write wrong results, so when she revise the results, always tired. She's always going to give some students more points over and over again, and pay attention to what the minimum score is. Can you help her?

What does this have to do with the artifact? God said: hehe.

Because the range of N and P is larger, it is recommended that C + + players read in scanf.
Write-read-in optimization is also recommended ....
The last point, pro-test pas read into 800+ms,c/c++ 's scanf 1200+ms, so the time limit for this point is changed to 2s
input/output format Input/output
Input format:
The first line has two integer n,p that represent the number of students and the number of times the score was increased.
The second line has n number, A1~an, representing each student's initial achievement.
The next P line, with three numbers per line, x, Y, Z, represents an increase in Z for each of the students from the nth to the nth.
Output format:
The output is only one line, which represents the lowest score for the class after the change.
input and Output sample sample Input/output
Sample test point # # Input Example:
3 2
1 1 1
1 2 1
2 3 1
Sample output:
2
Description description
For 40% of data, there are n<=1000
For 60% of data, there are n<=10000
For 80% of data, there are n<=100000
For 100% of the data, there are n<=5000000,p<=n, student initial scores <=100,z<=100*/

Idea: two array storage, loop add

The code is as follows:

1#include <stdio.h>2 intMain ()3 {4     Long Longn,p,i,t; 5     intb[24000];//The representative increases the Z-score for each student from the first x to the first Y. 6     Long LongK//The lowest score in the class7     Long Longa[24000];//Initial score8scanf"%i64d%i64d",&n,&p);9     /*=========================================*/Ten      for(i=0; i<n;i++)//Enter initial score One     { Ascanf"%d",&a[i]); -     } -     /*=========================================*/ the      for(i=0; i<p*3; i++)//enter "for the number of x to Y students per person to increase the Z-score" -     { -scanf"%d",&B[i]);  -     } +     /*=========================================*/ -      for(i=0; i<p;i++) +     { A          for(t=b[i*3]-1; t<=b[i*3+1]-1; t++) at         { -a[t]=a[t]+b[i*3+2]; -         } -     }     -     /*=========================================*/     -k=a[0]; in      for(i=0; i<n;i++)//the lowest score -     { to         if(a[i]<k) k=a[i];//sweep from front to tail and find a small, assigned value +     } -printf"\n%i64d\n", k);//Output Minimum score the     return 0; *}

Rokua-Chinese results [prize] Rokua May Month: The three great artifacts of KKKSC03

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.