제출 #1322280

#제출 시각아이디문제언어결과실행 시간메모리
1322280tleSquaredSnail (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]; for (int i = 1; i < n; i++) sum[i] = sum[i-1]+a[i]; ll rep = sum[n-1]; sort(sum.begin(), sum.end()); if (rep <= 0) { cout << "-1 -1\n"; return; } ll ans = ceil((h-sum[n-1])/(double)rep); ll cur = ans*rep; if (cur >= h) { cout << ans-1 << " " << n-1 << endl; return; } for (int i = 0; i < n; i++) { cur += a[i]; if (cur >= h) { cout << ans << " " << 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...