Submission #1071514

#TimeUsernameProblemLanguageResultExecution timeMemory
1071514zh_hSnail (NOI18_snail)C++17
0 / 100
1095 ms604 KiB
#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; //* while taking the input, find: //* 1. the average move per day //* 2. the highest that you can reach per day vector<lint> p; lint ave=0, highest=0, lowest=0; lint count=0; for(lint i = 0; i < n; i ++){ lint temp; cin >> temp; p.pb(temp); count += temp; // if(count < 0){count = 0;} highest = max(highest, count); lowest = min(lowest, count); ave += temp; } // cout << highest << endl << lowest << endl; lowest *= -1; lint total = 0; lint days = 0; bool is_done = false; while(total < lowest && total < height){ if(days > 1e3){is_done = true; cout << -1 << " " << -1; break;} // cout << days << " "; for(int i = 0; i < n; i ++){ total += p[i]; if(total < 0){total = 0;} if(total >= height){is_done = true; cout << days << " " << i; break;} } days++; } if(!is_done){ while(total < height-highest){ total += ave; days++; } for(int i = 0; i < n; i ++){ total += p[i]; if(total >= height){cout << days << " " << i;} } } 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 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...