제출 #528171

#제출 시각아이디문제언어결과실행 시간메모리
528171AndresTLArchery (IOI09_archery)C++11
10 / 100
2099 ms4208 KiB
#include<bits/stdc++.h>
using namespace std;
const int LIMIT=200000;
int level[(2*LIMIT)+2];
int Objetivos, Rounds, MyArcher;
int solve(int ini){
  vector<pair<int,int>> Obj;
  int z=1;
  ///cout<<"-----\n";
  for(int i=2;i<=Objetivos*2;i+=2){
    if(ini==z){
      Obj.push_back(make_pair(level[i],MyArcher));  
      i--;
    }else{
      Obj.push_back(make_pair(level[i],level[i+1]));
    }
    ///cout<<Obj.back().first<<' '<<Obj.back().second<<'\n';
    z++;
  }

  int ultimo=0;
  int pos=0;
  for(int i=1;i<=Rounds;i++){
    for(int j=0;j<Objetivos;j++){
      if(j==0){
        if(Obj[j].first<Obj[j].second){
          ultimo=Obj[j].second;
        }else{
          ultimo=Obj[j].first;
          Obj[j].first=Obj[j].second;
        }
        Obj[j].second=-1;
        if(Obj[j].first==MyArcher){
          pos=j+1;
        }else if(ultimo==MyArcher){
          pos=Objetivos;
        }
      }else{
        if(Obj[j].first<Obj[j].second){
          Obj[j-1].second=Obj[j].first;
          Obj[j].first=Obj[j].second;
        }else{
          Obj[j-1].second=Obj[j].second;
        }
        Obj[j].second=-1;
        if(Obj[j].first==MyArcher){
          pos=j+1;
        }else if(Obj[j-1].second==MyArcher){
          pos=j;
        }
      }
    }
    Obj[Objetivos-1].second=ultimo;    
  }
  return pos;
};
int main(){
  ios_base::sync_with_stdio(0);cin.tie();
  cin>>Objetivos>>Rounds>>MyArcher;
  for(int i=2;i<=Objetivos*2;i++){
    cin>>level[i];
  }
  int gano,mgano=100000;
  int res=0;
  for(int i=1;i<=Objetivos;i++){
    gano=solve(i);
    if(mgano>=gano){
      mgano=gano;
      res=i;
    }
  }
  cout<<res<<'\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...