Submission #5627220


Source Code Expand

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
const long long INF = 1LL << 60;
using namespace std;

int n;
int p[100];
bool dp[110][10010];

int main(){
	cin >>n;
	cinf(n,p);
	dp[0][0]=true;
	for(int i=0;i<n;i++){
		for(int j=0;j<=10010;j++){
			if(dp[i][j]){
				dp[i+1][j+p[i]]=true;
				dp[i+1][j]=dp[i][j];
			}
		}
	}
	ll ans=0;
	for(int i=0;i<10010;i++){
		if(dp[n][i])ans++;
	}
	cout << ans << endl;
}

Submission Info

Submission Time
Task A - コンテスト
User KKT89
Language C++14 (GCC 5.4.1)
Score 2
Code Size 566 Byte
Status AC
Exec Time 2 ms
Memory 896 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:14: warning: iteration 10010u invokes undefined behavior [-Waggressive-loop-optimizations]
    if(dp[i][j]){
              ^
./Main.cpp:20:16: note: containing loop
   for(int j=0;j<=10010;j++){
                ^

Judge Result

Set Name All
Score / Max Score 2 / 2
Status
AC × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 AC 1 ms 256 KB
01 AC 2 ms 512 KB
02 AC 2 ms 896 KB
90 AC 1 ms 256 KB
91 AC 1 ms 256 KB