답안 #22747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22747 2017-04-30T07:12:44 Z 버거킹 송죽SK점 우수고객(#1039, Namnamseo, khsoo01) Unifying Values (KRIII5_UV) C++14
0 / 7
500 ms 2708 KB
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;

int n, a[10005], s[10005], ans;
int pa[10005], pb[10005], dt[10005];
unordered_map<int, int> mp;

int solve (int idx) {
	mp.clear();
	for(int i=1;i<=n;i++) {
		pa[i] = mp[s[i]-s[idx]];
		pb[i] = mp[s[i]];
		mp[s[i]] = i;
	}
	for(int i=0;i<idx;i++) dt[i] = 0;
	dt[idx] = 1;
	for(int i=idx+1;i<=n;i++) {
		dt[i] = dt[pa[i]] + dt[pb[i]];
	}
	return dt[n];
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		s[i] = s[i-1] + a[i];
	}
	for(int i=1;i<=n;i++) {
		ans = (ans + solve(i)) % mod;
	}
	printf("%d\n",(ans+mod-1)%mod);
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:26:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
UV.cpp:28:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2220 KB Output is correct
2 Correct 0 ms 2220 KB Output is correct
3 Correct 0 ms 2220 KB Output is correct
4 Execution timed out 500 ms 2708 KB Execution timed out
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 500 ms 2352 KB Execution timed out
2 Halted 0 ms 0 KB -