Submission #209514

# Submission time Handle Problem Language Result Execution time Memory
209514 2020-03-14T12:30:31 Z model_code Snail (NOI18_snail) C++17
17 / 100
6 ms 380 KB
#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;
		}
	}
}

Compilation message

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 time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Incorrect 5 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -