제출 #209514

#제출 시각아이디문제언어결과실행 시간메모리
209514model_codeSnail (NOI18_snail)C++17
17 / 100
6 ms380 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100005;
ll H, N, A[MAXN], sum;
int main() {
	scanf("%lld%lld", &H, &N);
	for (int i = 0; i < N; ++i) {
		scanf("%lld", &A[i]);
		sum += A[i];
		if (sum >= H) {
			printf("0 %d\n", i);
			return 0;
		}
	}
	if (sum == 0) {
		puts("-1 -1");
		return 0;
	}
	ll left = H % sum;
	if (left == 0) {
		printf("%lld %d\n", H/sum-1, N-1);
		return 0;
	}
	for (int i = 0; i < N; ++i) {
		left -= A[i];
		if (left <= 0) {
			printf("%lld %d\n", H/sum, i);
			return 0;
		}
	}
}

컴파일 시 표준 에러 (stderr) 메시지

snail.cpp: In function 'int main()':
snail.cpp:22:35: warning: format '%d' expects argument of type 'int', but argument 3 has type 'll {aka long long int}' [-Wformat=]
   printf("%lld %d\n", H/sum-1, N-1);
                                ~~~^
snail.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &H, &N);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
snail.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &A[i]);
   ~~~~~^~~~~~~~~~~~~~~
#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...