#include <bits/stdc++.h>
#include <unistd.h>
#include <set>
#define dbg(x) cout<<#x<<" has a value of: "<<x<<"\n";
typedef long long int lli;
using namespace std;
typedef pair<lli,lli> pii;
int main(){
int n;
cin>>n;
int ttl=0;
vector<string> dizi(n);
vector<pii> prs(n);
for (int i = 0; i < n; i++)
{
cin>>dizi[i];
int a,b;
cin>>a>>b;
prs[i]=pii(a,b);
}
int mx=-1;
string cvb="";
for(int i=n-1;i>=0;i--){
int nb=prs[i].second;
int lc=0;
while(nb>=prs[i].first){
nb-=prs[i].first;
nb+=2;
lc++;
ttl++;
}
if(lc>=mx){
mx=lc;
cvb=dizi[i];
}
}
cout<<ttl<<"\n"<<cvb<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
252 KB |
Output is correct |
13 |
Correct |
2 ms |
256 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 |
256 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 |
380 KB |
Output is correct |
22 |
Correct |
2 ms |
256 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 |
376 KB |
Output is correct |