UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#192976#3402. 吃土豆diamond_plus1001ms1176kbC++111.6kb2023-10-14 08:34:522023-10-14 12:03:45

answer

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

#define rd read()
#define int long long

const int N = 1e3 + 10;
const int MOD = 998244353;
const int INF = 0x7fffffff;
const int Fill = 0x3f;
const int FillINF = 0x3f3f3f3f;

void write(int n)
{
    if (n < 0)
    {
        putchar('-');
        n = -n;
    }
    if (n < 10)
    {
        putchar(n + '0');
        return;
    }
    write(n / 10);
    putchar(n % 10 + '0');
    return;
}
void wt(int n, bool o = 1)
{
    write(n);
    if (!o)
    {
        putchar(' ');
    }
    else
    {
        putchar('\n');
    }
}

int read()
{
    char ch;
    int type = 1, n = 0;
    ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
        {
            type = -1;
        }
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        n = (n << 1) + (n << 3) + (ch ^ 48);
        ch = getchar();
    }
    return n * type;
}

int n, s;
int v[N], a[N];

void solve()
{
    int i, j;
    n = rd;
    s = rd;
    for (i = 1; i <= n; i++)
    {
        v[i] = rd;
    }
    for (i = 1; i <= n; i++)
    {
        a[i] = rd;
    }
    for (i = 1;; i = a[i])
    {
        s -= v[i];
        if (s <= 0)
        {
            cout << i;
            return;
        }
    }
}

signed main()
{
    int T;
    int i, j;
    T = 1;
    while (T--)
    {

        solve();
    }
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1164kb

input:

1 888
1
1

output:

1

result:

ok single line: '1'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1164kb

input:

3 995
1 27 74
3 2 1

output:

3

result:

ok single line: '3'

Test #3:

score: 10
Accepted
time: 1ms
memory: 1168kb

input:

2 894
30 51
1 1

output:

1

result:

ok single line: '1'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1172kb

input:

722 938
17 20 28 1 61 27 41 12 9 73 10 14 6 24 26 5 6 12 15 26 89 82 16 18 16 13 18 29 137 35 80 21 ...

output:

31

result:

ok single line: '31'

Test #5:

score: 10
Accepted
time: 0ms
memory: 1172kb

input:

933 995
7 5 19 25 65 15 8 75 5 35 17 9 30 8 18 22 50 39 20 18 11 26 24 33 59 46 52 55 20 65 75 54 58...

output:

32

result:

ok single line: '32'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1172kb

input:

657 965
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

568

result:

ok single line: '568'

Test #7:

score: 10
Accepted
time: 0ms
memory: 1172kb

input:

868 950
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

506

result:

ok single line: '506'

Test #8:

score: 10
Accepted
time: 0ms
memory: 1176kb

input:

578 981
27 4 1 5 85 41 32 43 56 92 53 57 100 11 1 25 36 84 40 3 10 17 72 11 9 3 115 25 68 22 65 59 4...

output:

56

result:

ok single line: '56'

Test #9:

score: 10
Accepted
time: 0ms
memory: 1172kb

input:

796 935
15 48 70 34 96 24 4 14 42 40 91 39 18 116 64 70 12 14 52 101 29 1 1 22 37 24 15 49 15 38 62 ...

output:

790

result:

ok single line: '790'

Test #10:

score: 10
Accepted
time: 0ms
memory: 1176kb

input:

675 999
23 74 26 12 80 27 5 15 31 27 70 2 58 12 19 43 6 19 45 5 2 29 48 14 28 15 15 59 29 43 6 28 42...

output:

666

result:

ok single line: '666'

Extra Test:

score: 0
Extra Test Passed