제출 #1322295

#제출 시각아이디문제언어결과실행 시간메모리
1322295tleSquaredSnail (NOI18_snail)C++20
37 / 100
1 ms568 KiB
#include <bits/stdc++.h> #define endl '\n' #define flash ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); #define ll long long #define ull unsigned ll using namespace std; void solve() { ll n, h; cin >> h >> n; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<ll> sum(n); sum[0] = a[0]; ll max_sum = a[0]; for (int i = 1; i < n; i++) { sum[i] = sum[i-1]+a[i]; max_sum = max(max_sum, sum[i]); } ll rep = sum[n-1]; if (rep <= 0) { cout << "-1 -1\n"; return; } ll ans = (h-max_sum)/rep; ll cur = ans*rep; for (int i = 0; i < n; i++) { cur += a[i]; if (cur >= h) { cout << ans << " " << i << endl; return; } } for (int i = 0; i < n; i++) { cur += a[i]; if (cur >= h) { cout << ans+1 << " " << i << endl; return; } } assert(false); } int main() { flash; solve(); return 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...