Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("roata.in");
  7. ofstream fout("roata.out");
  8.  
  9. struct cabina{
  10. int de;bool oc = false;
  11. }a[10001];
  12.  
  13. bool ok = true;
  14.  
  15. cabina cab[361];
  16.  
  17. int n,p,v[100001],r=1,s=0;
  18.  
  19. int main()
  20. {
  21. fin >> n >> p;
  22. for(int i = 1;i<=p;i++){
  23. fin >> v[i];
  24. if(cab[n].oc == false){
  25. cab[i].de = i;
  26. cab[i].oc = true;
  27. r++;
  28. }
  29. s+= v[i];
  30. }
  31. fout << s << endl;
  32. while(ok){
  33. for(int i = 1;i<=n;i++){
  34. v[cab[i].de]--;
  35. if(v[cab[i].de] == 0){
  36. fout << cab[i].de << " ";
  37. cab[i].de = r;
  38. r++;
  39. if(r-n > p){
  40. fout << endl << i;
  41. ok = false;
  42. break;
  43. }
  44. }
  45. }
  46. }
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement