Submission #1071819

# Submission time Handle Problem Language Result Execution time Memory
1071819 2024-08-23T11:36:23 Z zh_h Snail (NOI18_snail) C++17
100 / 100
2 ms 856 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 height, n;
    cin >> height >> n;
    vector<lint> p;
    lint ave=0;
    lint day0 = 0;
    for(lint i = 0; i < n; i ++){
        lint temp;
        cin >> temp;
        p.pb(temp);
       
        ave += temp;
        
        day0 += temp;
        if(day0 < 0){day0 = 0;}
    }

    
    bool check = false;
    lint total = 0;
    for(lint j = 0; j < 2; j ++){
        for(lint i = 0; i < n; i ++){
            total += p[i];
            if(total < 0){total = 0;}
            // cout << total << endl;
            if(total >= height){check = true; cout << j << " " << i; break;}
        }
        if(total >= height){break;}
    }

    if(ave <= 0 && !check){cout << -1 << " " << -1;}
    else if(!check){
        // cout << "hehe\n";
        lint highest = 0;
        lint count = day0;
        for(lint i = 0; i < n; i ++){
            count += p[i];
            highest = max(highest, count);
        }

        highest -= day0;

        // cout << height << " " << day0 << " " << highest << " " << ave << endl;

        lint N = (height - day0 - highest + ave - 1)/ave;

        total = (N*ave)+day0;
        // cout << N << " " << total << endl;

        for(lint i = 0; i < n; i ++){
            // cout << "haha ";
            total += p[i];
            if(total >= height){
                // cout << total << endl;
                cout << N+1 << " " << i;
                break;
            }
        }
        

    }

    return 0;
}

// 10 3
// 2 -10 8
// 1 0
 
// 5 1
// -1
// -1 -1
 
// 5 2
// 4 -2
// 1 0
 
// 3 1
// 1
// 2 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 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 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 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 1 ms 736 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 604 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 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 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 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 856 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 1 ms 736 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 604 KB Output is correct
32 Correct 1 ms 604 KB Output is correct