Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- ios_base::sync_with_stdio(0), cin.tie(0);
- // freopen("chores.in", "r", stdin);
- int n, l;
- cin >> n >> l;
- int adds[l];
- int cow[n];
- for(int i=1; i<=l; i++){
- cin >> adds[i];
- // cout << "adds[i]: " << adds[i] << '\n';
- }
- for(int i=1; i<=n; i++){
- cow[i] = i;
- }
- // cout << "HI" << '\n';
- int idx = 0;
- int active = 0;
- int val = 0;
- for(int i=1; i<=n-1; i++){
- idx++;
- active = adds[idx];
- // cout << "adds[idx]: " << adds[idx] << '\n';
- int skip = 0;
- // cout << "loop: " << i << "(" << val << " + " << active+skip << ")";
- for(int j=1; j<=active; j++){
- val++;
- if(val>n){
- val=val%n;
- }
- while(cow[val] == 0){
- val++;
- if(val>n){
- val=val%n;
- }
- skip++;
- // cout << "HI" << '\n';
- }
- }
- // cout << ", check array - > " << ", skip: " << skip << ", used: " << val << '\n';
- cow[val] = 0;
- idx = idx%l;
- }
- // cout << "HI2" << '\n';
- for(int i=1; i<=n-1; i++){
- if(cow[i] != 0){
- cout << cow[i] << '\n';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement