https://codeforces.net/problemset/problem/749/A i did understood the question that we need to find the sum of primes that is equal to n and count of those primes but am not able to get the logic how to do it can anyone help me .. with the logic part
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 150 |
https://codeforces.net/problemset/problem/749/A i did understood the question that we need to find the sum of primes that is equal to n and count of those primes but am not able to get the logic how to do it can anyone help me .. with the logic part
link to the problem https://codeforces.net/contest/1915/problem/E
my code
using namespace std;
signed main() { int t; cin >> t; while (t--) { int n; cin >> n; std::vector a(n+1);
unordered_map<int, int> sum_map; sum_map[0] = 1; bool flag=false; int sum=0; for(int i = 1; i <= n; i++){ cin >> a[i]; if(i%2==0){ a[i]=-a[i]; } sum=sum+a[i]; sum_map[sum]++; if(sum_map[sum]>1){ flag =true; break; } } if(flag){ cout << "YES\n"; } else { cout << "NO\n"; } }
} why is tle coming in this and one more question when i am using the break in ok=true there as its been done why is still false coming ???? please help me
as i have seen when ever the matrix or pattern problems comes i am able to understand it but i am not able to apply or think of any logic can anyone suggest me what should i do.... or if i can learn things please do recommand me.....
Name |
---|