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

Ended

Participants:356

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-27 13:24:45

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<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
using namespace std;
int a[100005];
int dp[200005];
vector<int> G[100005];
int main()
{
    int n,q;
    int ans=1999999999;
    int sum=0;
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++)scanf("%d",&a[i]);
    for(int i = n - 1 ; i >= 0 ; i--)
    {
        dp[i]=1;
        if(i+a[i]<n)dp[i]+=dp[i+a[i]];
    }
    for(int i = 0 ; i < 6 ; i++)
    {
        for(int j = i ; j < n ;)
            G[j].push_back(i),j+=a[j];
    }
    scanf("%d",&q);
    while(q--)
    {
        int x;
        scanf("%d",&x);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX