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("selection.in", "r", stdin);
- int n, t;
- cin >> n >> t;
- int card[n];
- for(int i=0; i<n; i++){
- cin >> card[i];
- // cout << card[i] << '\n';
- }
- // cout << "HI" << '\n';
- for(int i=0; i<t; i++){
- int mx = 0;
- int pos = 0;
- // cout << "HI2" << '\n';
- for(int j=0; j<n; j++){
- // cout << "HI2" << '\n';
- if(card[j]>mx){
- mx = card[j];
- pos = j;
- }
- // cout << "card[j]: " << card[j] << ", mx: " << mx << ", pos: " << pos+1 << '\n';
- }
- card[pos] = 0;
- cout << pos+1 << '\n';
- // cout << pos+1 << '\n';
- int add = mx/(n-1);
- for(int x=0; x<n; x++){
- // cout << card[x] << '\n';
- if(x!=pos){
- card[x]+=add;
- }
- // cout << card[x] << '\n';
- }
- int mdval = mx%(n-1);
- // cout << "=====" << '\n';
- for(int y = 0; y<n; y++){
- if(y!=pos){
- card[y]+=1;
- mdval--;
- }
- if(mdval==0){
- break;
- }
- }
- // cout << "======" << '\n';
- // int addv = mx/(n-1);
- // for(int x=0; x<n; x++){
- // card[x] += addv;
- // cout << card[x] << '\n';
- // }
- }
- // cout << "pos: " << pos << '\n';
- // for(int i=0; i<t; i++){
- // // card[pos] = 0;
- // int mx = 0;
- // int pos = 0;
- // for(int j=0; j<n; i++){
- // // if(card[i]>mx){
- // // mx = card[i];
- // // pos = i;
- // // }
- // }
- // card[pos] = 0;
- // cout << pos+1 << '\n';
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement