[Offer收割]编程练习赛30 register

Ended

Participants:188

Verdict:Accepted
Score:100 / 100
Submitted:2017-10-08 13:23:38

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e6+5;
int A[N];
int main()
{
    int n,cost = 0,r = 1,max = 0,day;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>A[i];
    }
    while(r<=n)
    {
        for(int i=r;i<=n;++i)
        {
            if(max <= A[i])
            {
                max = A[i];
                day = i;
            }
        }
        for(int j=r;j<day;++j)
        {
            cost -= A[j];
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX