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. if(t +(work[a][0] == 1) ? 1 : work[a][0]-1 < day) {
  14. t += (work[a][0] == 1) ? 1 : work[a][0]-1;
  15. price += work[a][1];
  16. }
  17. }
  18.  
  19. if(t == day-1){
  20. if(maxt < price) maxt = price;
  21. }
  22. }
  23.  
  24. int main(){
  25. for(int i=0; i<day; i++){
  26. cal(i);
  27. }
  28.  
  29. cout << maxt;
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty