SOLBLTY - Editorial


Contest Division 1
Contest Division 2
Contest Division 3

Setter: Daanish Mahajan
Tester & Editorialist: Taranpreet Singh






Starting with 1 liter of water having solubility A\frac{g}{100 mL}. With each degree rise in temperature, solubility increases by B\frac{g}{100 mL}.

Determine the maximum solubility


  • The maximum solubility would be at temperature 100 degrees.
  • Simulate


Here, we have initial temperature of water, initial solubility, maximum temperature we can heat water to (100 degrees), and the additional solubility for every additional degree. We want to find maximum possible solubility.

Since we know that solubility increases as the water temperature rises, we’d want to raise the temperature as much as possible. Here, we cannot raise beyond 100 degrees.

Hence, the maximum possible solubility is the solubility at 100 degrees temperature.

In order to calculate solubility at temperature T, we can see that every rise in degree increases solubility by 10*B (Since there is 1 liter = 10*100mL water. Hence, Raising temperature from X to 100 raises solubility by (100-X)*10*B Initial solubility is 10*A

Hence, maximum solubility is 10*(A + (100-X)*B)

We can also find the same by simulating the heating process degree by degree which is also fast enough for given constraints to get AC.


The time complexity is O(1) per test case.


Setter's Solution
# define pb push_back 
#define pii pair<int, int>
#define mp make_pair
# define ll long long int

using namespace std;

const int maxt = 1e3;

int main()
    int t; cin >> t;
    int T, S, dS;
        cin >> T >> S >> dS;
        int ans = (S + (100 - T) * dS) * 10;
        cout << ans << endl;
Tester's Solution
import java.util.*;
class SOLBLTY{
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int X = ni(), A = ni(), B = ni();
        pn(10 * (A + (100-X)*B));
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    static boolean multipleTC = true;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();for(int t = 1; t<= T; t++)solve(t);
    public static void main(String[] args) throws Exception{
        new SOLBLTY().run();
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return;}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(;}
    long nl()throws Exception{return Long.parseLong(;}
    double nd()throws Exception{return Double.parseDouble(;}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(;

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
            return st.nextToken();

        String nextLine() throws Exception{
            String str = "";
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            return str;

Feel free to share your approach. Suggestions are welcomed as always. :slight_smile:

Easy Java Solution

import java.util.*;
import java.lang.*;

class Codechef
	public static void main (String[] args) throws java.lang.Exception
	        Scanner sc=new Scanner(;
		int T=sc.nextInt();
		for(int a0=0;a0<T;a0++){
		    int X=sc.nextInt();             //current temperature
    		int A=sc.nextInt();             
    		int B=sc.nextInt();
    		int solubility=(A+(100-X)*B)*10;              //formula to be applied

Nothing to do much in this question. Simply apply the formula and you’ll get the ans🙂

I literally have the exact same code why doesn’t it work

import java.util.;
import java.lang.

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
public static void main (String[] args) throws java.lang.Exception
Scanner s = new Scanner(;
int n = s.nextInt();

	for(int i = 1; i <= n; i++){
	    int x = s.nextInt();
	    int a = s.nextInt();
	    int b = s.nextInt();
	    int final = (b*(100-x)+a)*10;


the final keyword is already defined in java compiler, so use some other name for your variable and it will work

    int n = s.nextInt();

	for(int i = 1; i <= n; i++){
	    int x = s.nextInt();
	    int a = s.nextInt();
	    int b = s.nextInt();
	    int res = ((b*(100-x))+a)*10;
1 Like

thank you its solved