Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int tab[20],stala=300,wynik,wynik2,pom,od;
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int t,n;
- cin>>t;
- for(int i=1;i<=t;i++)
- {
- cin>>n;
- for(int j=1;j<=n;j++)
- {
- cin>>tab[i];
- }
- sort(tab+1,tab+n+1);
- for(int j=1;j<=n;j++)
- {
- if(tab[j]!=0)
- {
- od=j;
- break;
- }
- }
- for(int j=1;j<=n;j++)
- {
- if(stala-tab[j]>=0)stala-=tab[j];
- else
- {
- wynik=j-1;
- break;
- }
- cout<<stala<<"\n";
- }
- for(int j=1;j<=wynik;j--)
- {
- pom=wynik;
- wynik2+=tab[j]*pom;
- pom--;
- }
- cout<<wynik<<" "<<wynik2<<"\n";
- stala=300;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement