# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
584285 | denniskim | Snail (NOI18_snail) | C++17 | 2 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
ll H, n;
ll a[10010];
ll l, r;
ll maxx;
ll sum;
int main(void)
{
scanf("%lld %lld", &H, &n);
for(ll i = 1 ; i <= n ; i++)
{
scanf("%lld", &a[i]);
sum += a[i];
}
if(sum <= 0)
{
ll h = 0;
for(ll i = 1 ; i <= n ; i++)
{
h += a[i];
if(h >= H)
{
printf("0 %lld", i - 1);
return 0;
}
}
printf("-1 -1");
return 0;
}
ll h = 0;
for(ll i = 1 ; i <= n ; i++)
{
h += a[i];
maxx = max(maxx, h);
}
ll dap = (H - maxx) / sum;
dap = max(dap, 0LL);
h = sum * dap;
if(h >= H)
{
printf("%lld %lld", dap - 1, n - 1);
return 0;
}
for(ll i = 1 ; i <= n ; i++)
{
h += a[i];
if(h >= H)
{
printf("%lld %lld", dap, i - 1);
return 0;
}
}
dap++;
h = sum * dap;
if(h >= H)
{
printf("%lld %lld", dap - 1, n - 1);
return 0;
}
for(ll i = 1 ; i <= n ; i++)
{
h += a[i];
if(h >= H)
{
printf("%lld %lld", dap, i - 1);
return 0;
}
}
printf("-1 -1");
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |