fork download
  1. /* @
  2.  * Siddharth Maloo
  3. */
  4. #include <iostream>
  5. #include <vector>
  6. #include <map>
  7. #include <stack>
  8. #include <queue>
  9. #include <string.h>
  10. #include <string>
  11. #include <math.h>
  12. #include <algorithm>
  13. #include <cstring>
  14. #include <time.h>
  15. #include <fstream>
  16. #include <functional>
  17. #include <numeric>
  18. /////////////////
  19. #define ULL unsigned long long int
  20. #define GI ({int t;scanf("%d",&t);t;})
  21. #define GL ({unsigned long long int t;scanf("%llu",&t);t;})
  22. #define PInt(a) printf("%d\n",(a))
  23. #define PLng(a) printf("%llu\n",(a))
  24. #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
  25. /////////////////
  26. using namespace std;
  27. int p[101][101*101+1], a[101];
  28. int main () {
  29. int i, j, k, c=0, t, n;
  30. n = GI;
  31. FOR(i,0,n){
  32. a[i] = GI;
  33. }
  34.  
  35. p[1][a[0]] = k = 1;
  36. FOR(i,2,n+1){
  37. FOR(j,0,n*n+1){
  38. if( p[i][j] >= 2) {k=0;break;}
  39.  
  40. p[i][j] += j - a[i]> 0?(p[i-1][j]+p[i-1][j-a[i]]):0;
  41. p[i][j] += j == a[i] ? 1:0;
  42. p[i][j] += j<a[i] ? p[i-1][j]:0;
  43.  
  44. }
  45. if(k==0) break;
  46. }
  47. if ( k== 0) cout <<"got it :)";
  48. return 0;
  49. }
Success #stdin #stdout 0.01s 6748KB
stdin
7
10 27 15 22 55 66 99
stdout

Standard output is empty