Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- //*****************Data type**********************//
- typedef long long ll;
- typedef long long int lli;
- typedef unsigned long long ull;
- typedef unsigned long long int ulli;
- //*****************Map****************************//
- typedef map<int, int> mp;
- typedef map<int, string> mps;
- typedef map<int, char>mpc;
- typedef map<string, int>mpsi;
- typedef map<char, int>mpci;
- //****************Pair****************************//
- typedef pair<int, int> pii;
- typedef pair<string, string> pss;
- typedef pair<char, char> pcc;
- typedef pair<int, string> pis;
- typedef pair<int, char> pic;
- //*****************Vector************************//
- typedef vector<int> VI;
- typedef vector<string> VS;
- typedef vector<double> VD;
- typedef vector<lli> VLLI;
- typedef vector<VI> VVI;
- typedef vector<pii> VPI;
- //****************SET**************************//
- typedef set<int> SI;
- typedef set<string> SS;
- typedef set<char>SC;
- //-------------------------------------------------------------------------------//
- #define pp1(A) printf("%d\n",A)
- #define pp2(A,B) printf("%d %d\n",A,B)
- #define pp3(A,B,C) printf("%d %d %d\n",A,B,C)
- #define ss1(A) scanf("%d", &A)
- #define ssl(A) scanf("%lld", &A)
- #define ss2(A,B) scanf("%d,%d",&A,&B)
- #define ss3(A,B,C) scanf("%d,%d,%d",&A,&B,&C)
- //--------------------------------------------------------------------------------//
- #define nosync ios_base::sync_with_stdio(false), cin.tie(NULL)
- #define pf push_front
- #define pb push_back
- #define popb pop_back()
- #define popf pop_front()
- #define itr iterator
- #define mk make_pair
- #define ff first
- #define ss second
- #define END return 0
- #define line printf("\n")
- #define yes printf("YES\n")
- #define no printf("NO\n")
- #define enter printf("Entered\n")
- #define Case(k,n) printf("Case %d: %d\n",k,n)
- #define sq(a) (a)*(a)
- #define SZ(a) (int)a.size()
- #define all(a) (a).begin(), (a).end()
- #define sortV(v) sort(all(v))
- #define sortA(a,n) sort(a,a+n)
- #define Erase(V,I) (V).erase((V).begin()+I)
- #define Insert(V,I,M) (V).insert((V).begin()+I,M)
- #define max3(a,b,c) max(max(a,b),c)
- #define max4(a,b,c,d) max(max3(a,b,c),d)
- #define min3(a,b,c) min(min(a,b),c)
- #define min4(a,b,c,d) min(min3(a,b,c),d)
- #define READ() freopen("input.txt", "r", stdin)
- #define WRITE() freopen("output.txt", "w", stdout)
- //********************************************************************************//
- #define loop(i,n) for(int i=0;i<n;i++)
- #define loops(i,x,n) for(int i=x;i<n;i++)
- #define loopr(i,n) for(int i=n-1;i>=0;i--)
- #define loopt(i,n) for(int i=1;i<=n;i++)
- #define vin(V, N) for(int i=0; i<N; i++){ int X; ss1(X); V.pb(X); }
- #define vinll(V, N) for(int i=0; i<N; i++){ lli X; ssl(X); V.pb(X); }
- #define scanA(A, N) for(int i=0; i<N; i++){ ss1(A[i]); }
- #define scanAll(A, N) for(int i=0; i<N; i++){ ssl(A[i]); }
- #define printA(A, N) for(int i=0; i<N; i++){ cout<<A[i]; if (i<N-1)cout<<" ";else cout<<endl; }
- #define vout(v) for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout <<" "; else cout << endl;}
- /*-----------------------GCD && LCM------------------*/
- int gcd(int a, int b)
- {
- return b == 0 ? a : gcd(b, a % b);
- }
- int lcm(int a, int b)
- {
- return a * (b / gcd(a, b));
- }
- /*----------------------Graph Moves----------------*/
- int ROW[]= {+1,-1,+0,+0};
- int COL[]= {+0,+0,+1,-1};
- /*----------------------Kings Move-----------------*/
- int X[]= {+0,+0,+1,-1,-1,+1,-1,+1};
- int Y[]= {-1,+1,+0,+0,+1,+1,-1,-1};
- /*----------------------Knights Move----------------*/
- int KX[]= {-2, -2, -1, -1, 1, 1, 2, 2};
- int KY[]= {-1, 1, -2, 2, -2, 2, -1, 1};
- //---------------------------------*START*-----------------------------------------//
- bool flag;
- int solve=0,penalty=0;
- struct student
- {
- int id,solve,tp,m;
- int solve_after,tp_after;
- int m1[60];
- };
- int main()
- {
- int k;
- cin>>k;
- int shad=0;
- lol:
- while(k--)
- {
- shad++;
- struct student st[50];
- int n;
- cin>>n;
- int c[n];
- loop(i,n)
- {
- cin>>st[i].id;
- cin>>st[i].solve;
- cin>>st[i].tp;
- cin>>st[i].m;
- int x=st[i].m;
- //cout<<x<<endl;
- st[i].solve_after=st[i].solve+x;
- st[i].tp_after=st[i].tp;
- loop(j,x)
- {
- cin>>st[i].m1[j];
- st[i].tp_after+=st[i].m1[j];
- }
- }
- loop(i,n)
- {
- cin>>c[i];
- }
- int pp,sol;
- loop(i,n)
- {
- int count=0;
- loop(j,n)
- {
- if(c[i]==st[j].id)
- {
- if(i==0)
- {
- sol=st[j].solve_after;
- pp=st[j].tp_after;
- }
- else
- {
- if(st[j].solve>sol)
- {
- cout<<"Case "<<shad<<": Say no to rumour >:"<<endl;
- goto lol;
- }
- else if(st[j].solve_after<sol)
- {
- sol=st[j].solve_after;
- pp=st[j].tp_after;
- //cout<<" We respect our judges :)"<<endl;
- }
- else if(st[j].solve_after==sol and st[j].tp_after>=pp)
- {
- sol=st[j].solve_after;
- pp=st[j].tp_after;
- // cout<<"We respect our judges :)"<<endl;
- }
- else
- {
- int yy=st[j].m;
- int zz=st[j].m;
- yy--;
- int cheak=0;
- //cout<<"Penalty before "<<st[j].tp_after<<endl;
- while(st[j].solve_after>st[j].solve )
- {
- st[j].solve_after--;
- st[j].tp_after-=st[j].m1[yy];
- yy--;
- if(st[j].solve_after<sol)
- {
- sol=st[j].solve_after;
- pp=st[j].tp_after;
- cheak=1;
- //no;
- break;
- }
- else if(st[j].solve_after==sol and st[j].tp_after>=pp)
- {
- sol=st[j].solve_after;
- pp=st[j].tp_after;
- cheak=1;
- //yes;
- break;
- }
- }
- if(!cheak)
- {
- cout<<"Case "<<shad<<": Say no to rumour >:"<<endl;
- goto lol;
- }
- }
- }
- }
- }
- //cout<<"Case solve "<<sol<<" penalty "<<pp<<endl;
- }
- cout<<"Case "<<shad<<": We respect our judges :)"<<endl;
- }
- END;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement