Submission #22394

# Submission time Handle Problem Language Result Execution time Memory
22394 2017-04-30T04:22:35 Z dried chocochip on Daegu asphalt(#897, suzy, zych1751, Acka) Unifying Values (KRIII5_UV) C++14
0 / 7
500 ms 4148 KB
#include <stdio.h>
#include <unordered_map>

#include <stdlib.h>
#include <time.h>

using namespace std;

#define MOD 1000000007

typedef long long lli;

unordered_map<lli,int> d[10000];
lli a[10000];
int n;

int main() {
	srand((unsigned)time(NULL));
	scanf("%d",&n);
	lli s=0;
	for(int i=0;i<n;i++) {
		scanf("%lld",&a[i]);
		s+=a[i];
		d[i][s]=1;
	}
	unordered_map<lli,int>::iterator mi;
	for(int i=1;i<n;i++) {
		lli sum=0;
		for(int j=i;j<n;j++) {
			sum+=a[j];
			mi=d[i-1].find(sum);
			if(mi!=d[i-1].end()) d[j][sum]+=mi->second;
			mi=d[j].find(sum);
			if(mi!=d[j].end() && d[j][sum]>=MOD) d[j][sum]-=MOD;
		}
	}
	int res=0;
	for(unordered_map<lli,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) {
		res+=it->second;
		if(res>=MOD) res-=MOD;
	}
	printf("%d\n",--res);
	return 0;
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:19:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
UV.cpp:22:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
                      ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2564 KB Output is correct
2 Correct 0 ms 2564 KB Output is correct
3 Correct 0 ms 2564 KB Output is correct
4 Execution timed out 500 ms 4148 KB Execution timed out
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 500 ms 3884 KB Execution timed out
2 Halted 0 ms 0 KB -