Openjudge 2705 Rope Skipping game

Source: Internet
Author: User

2705: Skipping games
Total time limit:
1000ms
Memory Limit:
65536kB
Describe
children play rope skipping competitions, to calculate how many jumps in a minute. Assuming a jump every second, it will take three seconds to start the jump if it fails halfway. The average child jumps a minute to jump a few times. It is now given the total number of hops that a child has jumped each time he jumps, and how many children have jumped within a minute. ( be careful to analyze sample data.)
Input
First act n a child
The rest of the rows, the first integer per line is the number of hops, and the remaining m integers are skipped as many times as they are skipped.
Output
The
output of the corresponding children jumped in the first minute how many down.
Sample input
603 12 23 45 1 174 10 20 30 405 10 20 30 40 58 6 10 20 30 40 47 60
Sample output
605157484847
Tips
tip, you may have timed out during the skipping game, but you are still counting, but the referee has stopped timing and got the score. Here is quite with oneself counted. Therefore, it is not the time of the first minute that the jump is bad. Note The sample data is analyzed.
 
Code:

#include <cstdio>
#include <malloc.h>
#include <algorithm>
using namespace std;

int main ()
{
Freopen ("In.txt", "R", stdin);
int m,i;
int t;
scanf ("%d", &t);
while (t--)
{
scanf ("%d", &m);
int *p= (int*) malloc (sizeof (int) *m);
for (i=0;i<m;i++)
scanf ("%d", &p[i]);
for (i=0;i<m;i++)
{
if (p[i]+3*i>60)
{
if (p[i-1]+3*i>=60)
printf ("%d\n", p[i-1]);
Else
printf ("%d\n", 60-3*i);
Break
}
}
if (i==m)
if (m!=0)
printf ("%d\n", Max (60-3*m,p[m-1]));
Else
printf ("60\n");
Free (p);
}
return 0;
}

Openjudge 2705 Rope Skipping game

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.