Submission #6234887
Source Code Expand
#include <stdio.h> #include <string.h> #include <vector> #include <string> #pragma warning(disable : 4996) #define MAX_N 100 #define MAX_P 100 #define INF 1000000000 template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } int Abs(int a) { if (a < 0) return a *= -1; return a; } int min(int a, int b) { if (a < b) return a; return b; } long long max(long long a, long long b) { if (a > b) return a; return b; } int N, W; int DP[MAX_N+1][MAX_N*MAX_P + 1]; int main(void) { scanf("%d", &N); for (int i = 0; i < MAX_N + 1; ++i) { for (int j = 0; j < MAX_N*MAX_P + 1; ++j) { DP[i][j] = -1; } } DP[0][0] = 0; for (int i = 1; i <= N; ++i) { int p; scanf("%d", &p); for (int j = 0; j <= MAX_N * MAX_P; ++j) { if (DP[i - 1][j] >= 0) DP[i][j] = 1; if (j - p >= 0) { if (DP[i - 1][j - p] >= 0) { DP[i][j] = 1; } } } } int sum = 0; for (int j = 0; j <= MAX_N * MAX_P; ++j) { if (DP[N][j] >= 0) ++sum; } printf("%d", sum); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - コンテスト |
User | ided345 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1217 Byte |
Status | WA |
Exec Time | 4 ms |
Memory | 4096 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:43:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.cpp:52:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &p); ^
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 0 / 2 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | WA | 3 ms | 4096 KB |
01 | WA | 3 ms | 4096 KB |
02 | WA | 4 ms | 4096 KB |
90 | WA | 3 ms | 4096 KB |
91 | WA | 3 ms | 4096 KB |