Submission #993186

# Submission time Handle Problem Language Result Execution time Memory
993186 2024-06-05T12:20:26 Z amine_aroua Uplifting Excursion (BOI22_vault) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using namespace std;
#define int long long
#define pb push_back
#define nl '\n'
#define fore(i, y) for(int i = 0; i < y; i++)
#define forr(i, x, y) for(int i = x;i<=y;i++)
#define forn(i, y, x) for(int i = y; i >= x; i--)

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int m , L;
    cin>>m>>L;
    int l[m + 1];
    int ans = 0;
    forr(i , -m , m)
    {
        int x;
        cin>>x;
        if(i > 0)
            l[i] = x;
        if(i == 0)
            ans+=x;
    }
    int sm = 0;
    if(L == 0)
    {
        cout<<ans<<nl;
        return 0;
    }
    if(L < 0)
    {
        cout<<"impossible"<<nl;
        return 0;
    }
    forr(i , 1 , m)
    {
        int x = min(l[i] , (L - sm)/i);
        if(sm + x * i == L)
        {
            cout<<ans+x<<nl;
            return 0;
        }
        if(sm + x * i < L && sm + (x + 1)* i > L)
        {
            cout<<ans + x - 1<<nl;
            return 0;
        }
        ans+=x;
        sm+=x * i;
    }
    if(sm < L)
    {
        cout<<"impossible"<<nl;
        return 0;
    }
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -