fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int work[15][2] = {{1,1},{1,2},{1,3},{1,4},{1,5}};
  5. int day=5;
  6. int maxt;
  7.  
  8. void cal(int i){
  9. int t=i;
  10. int price=0;
  11.  
  12. for(int a=i; a<day; a+=(work[a][0] == 1) ? 1 : work[a][0]-1){
  13. cout << t << ' ' << a << ' ' << price << endl;
  14. if(t +(work[a][0] == 1) ? 1 : work[a][0]-1 < day) {
  15. t += (work[a][0] == 1) ? 1 : work[a][0]-1;
  16. price += work[a][1];
  17. }
  18. }
  19.  
  20. if(t == day-1){
  21. if(maxt < price) maxt = price;
  22. }
  23. }
  24.  
  25. int main(){
  26. for(int i=0; i<day; i++){
  27. cal(i);
  28. }
  29.  
  30. cout << maxt;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
0 0 0
1 1 1
2 2 3
3 3 6
4 4 10
1 1 0
2 2 2
3 3 5
4 4 9
2 2 0
3 3 3
4 4 7
3 3 0
4 4 4
4 4 0
0