Advertisement
askarulytarlan

Untitled

Mar 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n, k, a[500], leading = 1, d, st[500], point;
  4. int main(){
  5. cin >> n >> k;
  6. for(int i = 1; i <= k; i++){
  7. cin >> a[i];
  8. }
  9. for(int i = 1; i <= n; i++){
  10. st[i] = i;
  11. }
  12. d = k;
  13. for(int i = 1; i <= k; i++){
  14. for(int j = leading; j <= n; j++){
  15. if(a[i] == 0){
  16. cout << st[j] << " ";
  17. st[j] = -1;
  18. }
  19. if(st[j] != -1){
  20. a[i]--;
  21. if(j == n){
  22. j = 0;
  23. }
  24. point = j + 1;
  25. }
  26. else{
  27. j--;
  28. }
  29. }
  30.  
  31. leading = point;
  32. }
  33. }
  34. //7 5
  35. //10 4 11 4 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement