Submission #1063393
Source Code Expand
#include <stdio.h> #include <string.h> #include <stdbool.h> #define N_MAX 100000 #define M_MAX 1000 #define INF 10000000 #define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b)))) typedef unsigned long long ull; typedef signed long long dll; dll a[M_MAX]; int n, m; int i, j, k; void deb(){ return; } ull abs(dll n){ return (ull)((n > 0) ? n : -n); } void solve(){ dll result = 0; dll total = 0; dll rangetot = 0; for (i = 0; i < n; i++) { if (a[i] >= 0) total += a[i]; } for (i = 0; i < k; i++) { if (a[i] >= 0) total -= a[i]; rangetot += a[i]; } while (i <= n) { ull candid; candid = total; if (rangetot > 0) candid += rangetot; if (result < candid) result = candid; if (a[i-k] >= 0) total += a[i-k]; rangetot -= a[i-k]; if (a[i] >= 0) total -= a[i]; rangetot += a[i]; i++; } printf("%lld\n", result); return; } int main (void) { scanf("%d%d", &n, &k); for (i = 0; i < n; i++) scanf("%lld", &a[i]); solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Contiguous Repainting |
User | sheyasutaka |
Language | C (GCC 5.4.1) |
Score | 0 |
Code Size | 1040 Byte |
Status | RE |
Exec Time | 366 ms |
Memory | 128 KB |
Compile Error
./Main.c:22:5: warning: conflicting types for built-in function ‘abs’ ull abs(dll n){ ^ ./Main.c: In function ‘main’: ./Main.c:56:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &k); ^ ./Main.c:57:26: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] for (i = 0; i < n; i++) scanf("%lld", &a[i]); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 128 KB |
0_01.txt | AC | 1 ms | 128 KB |
0_02.txt | AC | 1 ms | 128 KB |
0_03.txt | AC | 1 ms | 128 KB |
1_00.txt | AC | 1 ms | 128 KB |
1_01.txt | AC | 1 ms | 128 KB |
1_02.txt | AC | 1 ms | 128 KB |
1_03.txt | RE | 366 ms | 128 KB |
1_04.txt | RE | 110 ms | 128 KB |
1_05.txt | RE | 109 ms | 128 KB |
1_06.txt | RE | 109 ms | 128 KB |
1_07.txt | RE | 109 ms | 128 KB |
1_08.txt | RE | 109 ms | 128 KB |
1_09.txt | RE | 110 ms | 128 KB |
1_10.txt | RE | 109 ms | 128 KB |
1_11.txt | RE | 109 ms | 128 KB |
1_12.txt | RE | 111 ms | 128 KB |
1_13.txt | RE | 109 ms | 128 KB |
1_14.txt | RE | 109 ms | 128 KB |
1_15.txt | RE | 110 ms | 128 KB |
1_16.txt | RE | 109 ms | 128 KB |
1_17.txt | RE | 109 ms | 128 KB |
1_18.txt | RE | 109 ms | 128 KB |
1_19.txt | RE | 109 ms | 128 KB |
1_20.txt | RE | 110 ms | 128 KB |
1_21.txt | RE | 112 ms | 128 KB |