fork(2) download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <string>
  9. #include <queue>
  10. #include <stack>
  11. #include <algorithm>
  12. #include <cmath>
  13. #include <iomanip>
  14. #define dibs reserve
  15. #define OVER9000 1234567890
  16. #define patkan 9
  17. #define tisic 47
  18. #define soclose 1e-9
  19. #define pi 3.1415926535898
  20. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  21. #define chocolate win
  22. #define ff first
  23. #define ss second
  24. #define abs(x) ((x < 0)?-(x):(x))
  25. #define uint unsigned int
  26. #include <time.h>
  27. // mylittlepony
  28. using namespace std;
  29.  
  30. int main() {
  31. // freopen("fcount.in","r",stdin);
  32. // freopen("fcount.out","w",stdout);
  33. int N;
  34. scanf(" %d",&N);
  35. vector< pair<int,int> > A(N+1);
  36. for(int i =0; i <= N; i++) {
  37. scanf(" %d",&A[i].ff);
  38. A[i].ss =i;}
  39. sort(A.begin(),A.end());
  40.  
  41. vector<int> ans;
  42. for(int i =0; i <= N; i++) {
  43. bool b =true;
  44. vector<int> B;
  45. for(int j =0; j < i; j++) B.push_back(A[j].ff);
  46. for(int j =i+1; j <= N; j++) B.push_back(A[j].ff);
  47. reverse(B.begin(),B.end());
  48. long long S =0;
  49. for(int j =0; j < N; j++) {
  50. S +=B[j];
  51. long long K =j*(j+1);
  52. for(int k =j+1; k < N; k++) K +=min(j+1,B[k]);
  53. if(S > K) {
  54. b =false;
  55. break;}}
  56. if(S%2 != 0) b =false;
  57. if(b) ans.push_back(A[i].ss);}
  58.  
  59. sort(ans.begin(),ans.end());
  60. printf("%d\n",ans.size());
  61. for(uint i =0; i < ans.size(); i++) printf("%d\n",ans[i]+1);
  62. return 0;}
  63.  
  64. // look at my code
  65. // my code is amazing
  66.  
Runtime error #stdin #stdout #stderr 0s 3432KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc