fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cmath>
  4. #define LL long long
  5. #define REP(a,b) for(int a=0; a<b; a++)
  6. #define FOR(a,b,c) for(int a=b; a < c; a++)
  7. #define FORD(a,b,c) for(int a=b-1; a >= c; a--)
  8. using namespace std;
  9. const int stala=1000003;
  10. int n,suma;
  11. LL czarne[stala+1];
  12. int szare[stala];
  13. int lewy(int i){return czarne[i]-czarne[i-1];}
  14. int prawy(int i){return czarne[n]-czarne[i];}
  15. int main()
  16. {
  17. scanf("%d\n",&n);
  18. FOR(i,1,n+1){
  19. scanf("%d",&czarne[i]);
  20. czarne[i]+=czarne[i-1];
  21. }
  22. szare[0]=0;
  23. REP(i,n)
  24. scanf("%d",&szare[i+1]);
  25. sort(szare,szare+n+1);
  26. REP(i,n){
  27. if(*lower_bound(szare,szare+n+1,lewy(i)-prawy(i))==lewy(i)-prawy(i))//czy mozna wymienic
  28. {
  29. if(*lower_bound(szare,szare+n+1,2*lewy(i))==2*(lewy(i)))
  30. {
  31. printf("%d\n",i);return 0;}
  32. }
  33. }
  34. printf("%d\n",n);
  35. return 0;
  36. }
  37.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19: warning: format ‘%d’ expects type ‘int*’, but argument 2 has type ‘long long int*’
prog.cpp:25: error: ‘sort’ was not declared in this scope
prog.cpp:27: error: ‘lower_bound’ was not declared in this scope
prog.cpp:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout
Standard output is empty