Submission #520407

#TimeUsernameProblemLanguageResultExecution timeMemory
520407meperdonas203Archery (IOI09_archery)C++17
11 / 100
2094 ms5984 KiB
#include<bits/stdc++.h> using namespace std; int r,n,yo; vector<int>habilidades; vector<pair<int,int>>campo; void ronda(){ for(int i=0;i<n;i++){ if(campo[i].first>campo[i].second){ swap(campo[i].first,campo[i].second); } } int aux=campo[0].second; campo[0].second=campo[1].first; for(int i=2;i<n;i++){ campo[i-1].first=campo[i].first; } campo[n-1].first=aux; } int comprueba(int pos){ int it=0; campo.clear(); campo.resize(n,{0,0}); campo[pos].first=habilidades[0]; for(int i=1;i<n*2;i++){ if(campo[it].first==0){ campo[it].first=habilidades[i]; }else if(campo[it].second==0){ campo[it].second=habilidades[i]; }else{ it++; i--; } } for(int i=1;i<=r;i++){ ronda(); } //for(auto x:campo)cout<<x.first<<' '<<x.second<<'\n'; for(int i=0;i<n;i++){ if(campo[i].first==yo or campo[i].second==yo)return i; } return n; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>r; habilidades.resize(n*2+2,0); campo.resize(n+2,{0,0}); for(int i=0;i<n*2;i++)cin>>habilidades[i]; yo=habilidades[0]; int ans=-1; int minima=INT_MAX; for(int i=0;i<n;i++){ int res=comprueba(i); //for(auto x:campo)cout<<x.first<<' '<<x.second<<'\n'; //cout<<res<<'\n'; if(res<=minima){ans=i; minima=res;} } cout<<ans+1<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...