Submission #1062478

# Submission time Handle Problem Language Result Execution time Memory
1062478 2024-08-17T07:45:10 Z zh_h Snail (NOI18_snail) C++17
37 / 100
2 ms 604 KB
#include <bits/stdc++.h>
#define lint long long
#define pb push_back
#define mp make_pair
using namespace std;
lint MOD = 1e9 + 7;
int INF = 1e9;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    lint h, p;
    cin >> h >> p;
    vector<lint> v;
    lint sum = 0;
    for(lint i = 0; i < p; i ++){
        lint temp;
        cin >> temp;
        v.pb(temp);
        sum += temp;
    }

    if(sum < 0){cout << -1 << " " << -1;}
    else if(sum == 0){
        lint h1 = 0;
        lint is_valid = -1;
        for(lint i = 0; i < p; i ++){
            if(h1 >= h){is_valid = i; break;}
            h1+=v[i];
            if(h1 < 0){h1 = 0;}
        }
        if(is_valid != -1){cout << 0 << " " << is_valid;}
        else cout << -1 << " " << -1;
    }
    else{
        lint m = 0;
        lint temp = 0;
        for(lint i = 0; i < p; i ++){
            temp += v[i];
            m = max(m, temp);
        }

        lint days = (h-m+sum-1)/sum;
        lint thatday = days*sum;
        lint valid;
        if(thatday >= h){
            thatday-=sum;
            days--;
        }
        
        for(lint i = 0; i < p; i ++){
            thatday += v[i];
            if(thatday >= h){valid = i; break;}
        }
        cout << days << " " << valid;
        
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -