Submission #143012

#TimeUsernameProblemLanguageResultExecution timeMemory
14301244442Go (COCI16_go)C++11
50 / 50
3 ms504 KiB
#include <bits/stdc++.h> using namespace std; int n,k[80],m[80],a[80],ok[80],b[80],c[80],e; string s[80]; pair<int,int>p[80]; int main (){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=0;i<n;i++){ cin>>s[i]>>k[i]>>m[i]; } for(int i=0;i<n;i++){ a[i]=m[i]/k[i]; ok[i]=2*a[i]+(m[i]-(a[i]*k[i])); while(ok[i]>=k[i]){ b[i]=ok[i]; ok[i]=ok[i]/k[i]; a[i]=a[i]+ok[i]; c[i]=ok[i]; ok[i]=ok[i]*2+(b[i]-(ok[i]*k[i])); } p[i]=make_pair(a[i],i); e=e+a[i]; } sort(p,p+n); int i=n-1; while(p[i].first==p[i-1].first){ i--; } cout<<e<<endl<<s[p[i].second]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...