Submission #22747

#TimeUsernameProblemLanguageResultExecution timeMemory
22747버거킹 송죽SK점 우수고객 (#40)Unifying Values (KRIII5_UV)C++14
0 / 7
500 ms2708 KiB
#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 (stderr)

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]);
                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...