Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //You won't understand the input format anyway unless you read an example input which i'll send soon.
- #include <bits/stdc++.h>
- using namespace std;
- int n,k;
- bool uz[101];
- int nc[101],mo[101];
- int coi[101][101],key[101][101],cost[101][101],nu[101][101],de[101][101],dv[101][101],tr[101][101],pr[101][101];
- string h[101];
- int main()
- {
- std::ios_base::sync_with_stdio(false);
- ifstream fin("maze.in");
- ofstream fout("maze.out");
- fin>>n;
- for (int i=0;i<n;++i) fin>>h[i];
- for (int i=0;i<n;++i)
- {
- fin>>nc[i];
- for (int j=0;j<n;++j) for (int k=0;k<4;++k) pr[k][j]=0;
- for (int j=0;j<nc[i];++j)
- {
- fin>>cost[i][j]>>coi[i][j]>>key[i][j];
- //coi[i][j]=0;
- nu[i][j+1]=nu[i][j]+cost[i][j]-coi[i][j];
- de[i][j+1]=de[i][j]+cost[i][j]-int(cost[i][j]*0.1)-coi[i][j];
- dv[i][j+1]=dv[i][j]+cost[i][j]-int(cost[i][j]*0.2)-coi[i][j];
- tr[i][j+1]=tr[i][j]+cost[i][j]-int(cost[i][j]*0.3)-coi[i][j];
- if (key[i][j])
- {
- --key[i][j];
- pr[0][key[i][j]]+=nu[i][j+1]-nu[i][0];
- pr[1][key[i][j]]+=de[i][j+1]-de[i][0];
- pr[2][key[i][j]]+=dv[i][j+1]-dv[i][0];
- pr[3][key[i][j]]+=tr[i][j+1]-tr[i][0];
- }
- }
- for (int j=0;j<4;++j)
- {
- for (int k=0;k<n;++k)
- {
- for (int l=0;l<k;++l) pr[j][k]=max(pr[j][k],pr[j][l]);
- }
- }
- for (int j=0;j<n;++j)
- {
- nu[j][0]+=pr[0][j];
- de[j][0]+=pr[1][j];
- dv[j][0]+=pr[2][j];
- tr[j][0]+=pr[3][j];
- if (j==2) cout<<i<<' '<<nu[j][0]<<endl;
- }
- }
- fout<<"No discount:"<<endl;
- for (int i=0;i<n;++i) fout<<"Mission "<<i+1<<'('<<h[i]<<") costs "<<nu[i][nc[i]]<<" maze coins with the keys, and "<<nu[i][nc[i]]-nu[i][0]<<" maze coins without the keys."<<endl;
- fout<<"10% discount:"<<endl;
- for (int i=0;i<n;++i) fout<<"Mission "<<i+1<<'('<<h[i]<<") costs "<<de[i][nc[i]]<<" maze coins with the keys, and "<<de[i][nc[i]]-de[i][0]<<" maze coins without the keys."<<endl;
- fout<<"20% discount:"<<endl;
- for (int i=0;i<n;++i) fout<<"Mission "<<i+1<<'('<<h[i]<<") costs "<<dv[i][nc[i]]<<" maze coins with the keys, and "<<dv[i][nc[i]]-dv[i][0]<<" maze coins without the keys."<<endl;
- fout<<"30% discount:"<<endl;
- for (int i=0;i<n;++i) fout<<"Mission "<<i+1<<'('<<h[i]<<") costs "<<tr[i][nc[i]]<<" maze coins with the keys, and "<<tr[i][nc[i]]-tr[i][0]<<" maze coins without the keys."<<endl;
- cout<<nu[2][0]<<endl;
- fout<<"0%: "<<nu[0][20]+nu[1][16]+nu[2][6]-nu[2][0]<<endl;
- fout<<"10%: "<<de[0][20]+de[1][16]+de[2][6]-de[2][0]<<endl;
- fout<<"20%: "<<dv[0][20]+dv[1][16]+dv[2][6]-dv[2][0]<<endl;
- fout<<"30%: "<<tr[0][20]+tr[1][16]+tr[2][6]-tr[2][0]<<endl;
- while (cin>>k)
- {
- for (int i=0;i<n;++i) uz[i]=0;
- int ma=0;
- for (int i=0;i<k;++i)
- {
- cin>>mo[i];
- --mo[i];
- ma=max(ma,mo[i]);
- uz[mo[i]]=1;
- }
- int amn=0,amd=0,amt=0,amf=0;
- for (int i=0;i<=ma;++i)
- {
- int dok=0;
- if (uz[i]) dok=nc[i];
- for (int j=0;j<nc[i];++j)
- {
- if (key[i][j]<=ma && key[i][j]>0) dok=max(dok,j+1);
- }
- amn+=nu[i][dok]-nu[i][0];
- amd+=de[i][dok]-de[i][0];
- amt+=dv[i][dok]-dv[i][0];
- amf+=tr[i][dok]-tr[i][0];
- cout<<dok<<endl;
- }
- for (int i=0;i<k-1;++i) fout<<h[mo[i]]<<'+';
- fout<<h[mo[k-1]]<<':'<<endl;
- fout<<"0%: "<<amn<<endl;
- fout<<"10%: "<<amd<<endl;
- fout<<"20%: "<<amt<<endl;
- fout<<"30%: "<<amf<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement