Submission #68974490
Source Code Expand
Copy
#include <stdio.h>#include <inttypes.h>int min(int a, int b) {return a <= b ? a : b;}int N, Q;int A[212345];int B[212345];char c[212345];int X[212345], V[212345];int main(void) {int i;int64_t ans;if (scanf("%d%d", &N, &Q) != 2) return 1;for (i = 1; i <= N; i++) {if (scanf("%d", &A[i]) != 1) return 1;}for (i = 1; i <= N; i++) {
#include <stdio.h>
#include <inttypes.h>
int min(int a, int b) {
return a <= b ? a : b;
}
int N, Q;
int A[212345];
int B[212345];
char c[212345];
int X[212345], V[212345];
int main(void) {
int i;
int64_t ans;
if (scanf("%d%d", &N, &Q) != 2) return 1;
for (i = 1; i <= N; i++) {
if (scanf("%d", &A[i]) != 1) return 1;
}
for (i = 1; i <= N; i++) {
if (scanf("%d", &B[i]) != 1) return 1;
}
for (i = 0; i < Q; i++) {
char buf[4];
if (scanf("%3s%d%d", &buf, &X[i], &V[i]) != 3) return 1;
c[i] = *buf;
}
ans = 0;
for (i = 1; i <= N; i++) {
ans += min(A[i], B[i]);
}
for (i = 0; i < Q; i++) {
ans -= min(A[X[i]], B[X[i]]);
(c[i] == 'A' ? A : B)[X[i]] = V[i];
ans += min(A[X[i]], B[X[i]]);
printf("%" PRId64 "\n", ans);
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Sum of Min Query |
| User | mikecat |
| Language | C (gcc 12.2.0) |
| Score | 300 |
| Code Size | 811 Byte |
| Status | AC |
| Exec Time | 94 ms |
| Memory | 6796 KiB |
Compile Error
Main.c: In function ‘main’:
Main.c:26:30: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[4]’ [-Wformat=]
26 | if (scanf("%3s%d%d", &buf, &X[i], &V[i]) != 3) return 1;
| ~~^ ~~~~
| | |
| char * char (*)[4]
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 0 ms | 1712 KiB |
| 00_sample_01.txt | AC | 0 ms | 1628 KiB |
| 00_sample_02.txt | AC | 0 ms | 1652 KiB |
| 01_random_00.txt | AC | 0 ms | 1632 KiB |
| 01_random_01.txt | AC | 74 ms | 6796 KiB |
| 01_random_02.txt | AC | 74 ms | 5008 KiB |
| 01_random_03.txt | AC | 44 ms | 3340 KiB |
| 01_random_04.txt | AC | 88 ms | 6416 KiB |
| 01_random_05.txt | AC | 42 ms | 3260 KiB |
| 01_random_06.txt | AC | 69 ms | 5780 KiB |
| 01_random_07.txt | AC | 26 ms | 2528 KiB |
| 01_random_08.txt | AC | 93 ms | 6636 KiB |
| 01_random_09.txt | AC | 90 ms | 6356 KiB |
| 01_random_10.txt | AC | 93 ms | 6688 KiB |
| 01_random_11.txt | AC | 85 ms | 5788 KiB |
| 01_random_12.txt | AC | 93 ms | 6684 KiB |
| 01_random_13.txt | AC | 94 ms | 6636 KiB |
| 01_random_14.txt | AC | 94 ms | 6692 KiB |
| 01_random_15.txt | AC | 93 ms | 6612 KiB |
| 01_random_16.txt | AC | 93 ms | 6580 KiB |
| 01_random_17.txt | AC | 93 ms | 6668 KiB |
| 01_random_18.txt | AC | 88 ms | 6424 KiB |
| 01_random_19.txt | AC | 92 ms | 6572 KiB |