Solution for DMOPC '19 Contest 1 P1 - Test Scores in C++


May 4, 2020 0.319835 seconds C++
#include <bits/stdc++.h>
using namespace std;


int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	long N;
	cin >> N;
	
	long n, a, b, t;
	for(int i = 0; i < N; i++){
		
		cin >> n >> a >> b >> t;
		
		double ans = ceil( 1.0 * (t + b * n) / (a + b));
		if(ans > n){
			cout << "-1\n";
		}else{
			cout << (int)round(ans) << "\n";
		}
		
	}

	return 0;
}

Editorial


No editorial for this problem. :(

Original Problem


You can view the original page for this problem on the DMOJ.