Submission #1134355
Source Code Expand
#include <stdio.h> int dp[2][10001]; int len; int p[100]; int main(){ int n, i, j, k, l; scanf("%d", &n); for(i=0;i<n;i++) scanf("%d", p+i); len = 1; for(i=0;i<n;i++){ int b = i&1; for(j=k=l=0;j<len&&k<len;){ if(dp[b][j] < dp[b][k] + p[i]) dp[b^1][l++] = dp[b][j++]; else if(dp[b][j] > dp[b][k] + p[i]) dp[b^1][l++] = dp[b][k++] + p[i]; else { dp[b^1][l++] = dp[b][j++]; k++; } } while(k<len) dp[b^1][l++] = dp[b][k++] + p[i]; while(j<len) dp[b^1][l++] = dp[b][j++]; len = l; } printf("%d\n", len); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - コンテスト |
User | ryuhei |
Language | C (GCC 5.4.1) |
Score | 2 |
Code Size | 594 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:9:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.c:10:20: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] for(i=0;i<n;i++) scanf("%d", p+i); ^
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 2 / 2 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | AC | 1 ms | 128 KB |
01 | AC | 1 ms | 128 KB |
02 | AC | 1 ms | 256 KB |
90 | AC | 1 ms | 128 KB |
91 | AC | 1 ms | 128 KB |