| Task: | Drink Responsibly |
| Sender: | wavelets |
| Submission time: | 2015-11-25 19:28:53 +0200 |
| Language: | C++ |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.05 s | details |
| #2 | ACCEPTED | 0.05 s | details |
| #3 | ACCEPTED | 0.06 s | details |
| #4 | ACCEPTED | 0.16 s | details |
| #5 | ACCEPTED | 0.07 s | details |
| #6 | RUNTIME ERROR | 0.28 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:34:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<v.size();++j){
^Code
#include <iostream>
#include <vector>
#include <cstdint>
#include <sstream>
using namespace std;
int64_t gcd(int64_t a,int64_t b){return b==0?a:gcd(b,a%b);}
struct fraction:pair<int64_t,int64_t>{
fraction(int64_t a=0,int64_t b=1):pair<int64_t,int64_t>(a,b){int64_t c=gcd(a,b);first/=c;second/=c;}
fraction operator-(const fraction&v){return fraction(first*v.second-second*v.first,second*v.second);}
fraction operator*(int64_t a){return fraction(first*a,second);}
};
struct node{
int pi;
string name;
int n;
int m;
fraction v;
};
int main(){
double mv,uv,d;
cin>>mv>>uv>>d;
int m=mv*100;
int u=uv*10;
vector<node> v;
v.push_back({-1,"",-1,m,fraction(u,1)});
for(int i=0;i<d;++i){
string name;
int p;
string fr;
cin>>name>>p>>fr>>uv;
int c=uv*100;
fraction f(p*10,fr[2]-'0');
vector<node> ins;
for(int j=0;j<v.size();++j){
auto& it = v[j];
if(it.m<c)continue;
int n=it.m/c+1;
while(--n>0){
fraction vvv = it.v-f*n;
if(vvv.first<0)continue;
ins.push_back({j,name,n,it.m-c*n,vvv});
}
}
v.insert(v.end(),ins.begin(),ins.end());
}
for(auto&it:v){
if(it.m!=0)continue;
if(it.v.first!=0)continue;
cout<<it.name<<' '<<it.n<<'\n';
int i=it.pi;
while(i>0){
cout<<v[i].name<<' '<<v[i].n<<'\n';
i=v[i].pi;
}
goto end;
}
cout<<"IMPOSSIBLE\n";
end:return 0;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 3.93 19.0 8 punkipa 4 1/1 0.27 deadpony 5 1/2 0.59 vagabond 3 1/1 0.27 thisislager 3 1/2 0.51 ... |
| correct output |
|---|
| bomber 1 kronenbourg 3 vagabond 2 vodka 2 |
| user output |
|---|
| kronenbourg 3 bomber 1 deadpony 4 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 3.59 17.0 8 punkipa 6 1/3 0.41 deadpony 6 1/1 0.63 vagabond 6 1/3 0.97 thisislager 1 1/3 0.08 ... |
| correct output |
|---|
| punkipa 4 vagabond 1 vodka 2 |
| user output |
|---|
| thisislager 9 punkipa 7 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 3.14 19.5 8 punkipa 6 1/3 0.01 deadpony 3 1/2 0.34 vagabond 6 1/3 0.85 thisislager 3 1/3 0.66 ... |
| correct output |
|---|
| bomber 1 fiveamred 4 kronenbourg 1 vagabond 1 vodka 1 |
| user output |
|---|
| vodka 1 kronenbourg 1 bomber 1 vagabond 1 punkipa 4 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 9.61 20.0 8 punkipa 1 1/2 0.63 deadpony 2 1/3 0.49 vagabond 2 1/3 0.80 thisislager 3 1/1 0.12 ... |
| correct output |
|---|
| bomber 2 fiveamred 5 kronenbourg 2 vagabond 2 vodka 4 |
| user output |
|---|
| bomber 1 fiveamred 11 thisislager 4 deadpony 5 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 6.24 16.1 8 punkipa 6 1/3 0.48 deadpony 3 1/3 0.09 vagabond 7 1/1 0.04 thisislager 1 1/2 0.76 ... |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| IMPOSSIBLE |
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| 5.84 20.0 8 punkipa 5 1/2 0.73 deadpony 4 1/1 0.94 vagabond 5 1/3 0.01 thisislager 5 1/2 0.62 ... |
| correct output |
|---|
| deadpony 2 fiveamred 4 vodka 8 |
| user output |
|---|
| (empty) |
