#include<bits/stdc++.h>
using namespace std;
#define pob pop_back
#define mp make_pair
#define pb push_back
#define mid (l+r)/2
#define test printf("test\n")
#define st first
#define nd second
#define superman ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
ll INF = 1e9;
ll mod = 1e9+7;
double pi = acos(-1);
ll l,k,m,n,ans,r;
int main() {
superman
//freopen("anan.gir","r",stdin);
//freopen(".cik","w",stdout);
cin>>n;
string str;
string ansstr;
cin>>str;
ansstr = str;
ll numevo=1;
ll numt=0;
cin>>k>>m;
ll ntt=0;
while(numevo!=0) {
numevo = m/k;
m-=numevo*k;
numt += numevo;
m += numevo*2;
}
// cout<<str<<' '<<numt<<endl;
ans = numt;
ntt = ans;
for(int i=1; i<n; i++) {
cin>>str;
numt=0;
cin>>k>>m;
numevo = 1;
while(numevo!=0) {
numevo = m/k;
m-=numevo*k;
numt += numevo;
m += numevo*2;
}
ntt += numt;
if(numt > ans) ansstr = str,ans = numt;
//cout<<str<<' '<<numt<<endl;
}
cout<<ntt<<endl<<ansstr<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
380 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
256 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
256 KB |
Output is correct |