Submission #926289

#TimeUsernameProblemLanguageResultExecution timeMemory
926289ToastSnail (NOI18_snail)C++14
25 / 100
1083 ms604 KiB
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

int main() {
    long H,N;
    long currentheight=0;
    long currentphase=0;
    long temp = -1;
    string P;
    bool flag=true;
    cin >> H >> N;
    cin.ignore();
    getline(cin, P);
    stringstream ss(P);
    vector<int>v;
    while (getline(ss,P,' ')) {
        v.push_back(stoi(P));
    }
    long currentday = -1;
    while (flag) {
        currentday++;
        for (int i=0;i<N;i++) {
            if (currentheight+v[i]<0) {
                currentheight = 0;
            }
            else {
                currentheight +=v[i];
            }
            if (currentheight>=H) {
                flag=false;
                currentphase=i;
                cout << currentday << " " << currentphase;
                break;
            }
        }
        if (temp==currentheight) {
            flag = false;
            cout << -1 << " " << -1; 
        }
        temp = currentheight;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...