Submission #56280190


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
const int N = 200005;
int a[N], n, m, b, c;
int main() {
scanf("%d %d", &n, &m);
b = -m;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
b = b + a[i];
}
if (b < 0) {
printf("infinite");
} else {
for (int i = 1; i <= b; i++) {
c = 0;
for (int k = 1; k <= n; k++) {
c = c + min(a[k], i);
}
if (c >= m) {
printf("%d", i - 1);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
const int N = 200005;
int a[N], n, m, b, c;
int main() {
	scanf("%d %d", &n, &m);
	b = -m;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		b = b + a[i];
	}
	if (b < 0) {
		printf("infinite");
	} else {
		for (int i = 1; i <= b; i++) {
			c = 0;
			for (int k = 1; k <= n; k++) {
				c = c + min(a[k], i);
			}
			if (c >= m) {
				printf("%d", i - 1);
				return 0;
			}
		}
	}
	return 0;
}

Submission Info

Submission Time
Task C - Transportation Expenses
User ybc2027_sunshiyi
Language C++ 20 (gcc 12.2)
Score 0
Code Size 469 Byte
Status WA
Exec Time 1052 ms
Memory 4656 KB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d %d", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf("%d", &a[i]);
      |                 ~~~~~^~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
WA × 1
AC × 5
WA × 23
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt
Case Name Status Exec Time Memory
00_sample_01.txt WA 1 ms 3676 KB
00_sample_02.txt AC 1 ms 3744 KB
00_sample_03.txt AC 1 ms 3868 KB
01_test_01.txt WA 22 ms 4472 KB
01_test_02.txt WA 1052 ms 4416 KB
01_test_03.txt WA 22 ms 4408 KB
01_test_04.txt WA 22 ms 4428 KB
01_test_05.txt WA 22 ms 4460 KB
01_test_06.txt WA 888 ms 4652 KB
01_test_07.txt WA 22 ms 4420 KB
01_test_08.txt WA 22 ms 4540 KB
01_test_09.txt WA 6 ms 3912 KB
01_test_10.txt WA 8 ms 3936 KB
01_test_11.txt WA 22 ms 4656 KB
01_test_12.txt WA 22 ms 4432 KB
01_test_13.txt WA 22 ms 4596 KB
01_test_14.txt WA 22 ms 4404 KB
01_test_15.txt WA 22 ms 4472 KB
01_test_16.txt WA 22 ms 4544 KB
01_test_17.txt WA 22 ms 4460 KB
01_test_18.txt WA 15 ms 4656 KB
01_test_19.txt WA 16 ms 4468 KB
01_test_20.txt WA 1 ms 3636 KB
01_test_21.txt AC 215 ms 4532 KB
01_test_22.txt WA 607 ms 4528 KB
01_test_23.txt AC 22 ms 4528 KB
01_test_24.txt WA 22 ms 4408 KB
01_test_25.txt AC 22 ms 4436 KB


2025-04-15 (Tue)
03:56:52 +00:00