Submission #67730782


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, j, k) for(int i = (j); i <= (k); i ++)
#define per(i, j, k) for(int i = (j); i >= (k); i --)
#define pb emplace_back
#define fi first
#define se second
using vi = vector<int>;
using pi = pair<int,int>;

template<typename T0, typename T1> bool chmin(T0 &x, const T1 &y){
	if(y < x){x = y; return true;} return false;
}
template<typename T0, typename T1> bool chmax(T0 &x, const T1 &y){
	if(y > x){x = y; return true;} return false;
}

template<typename T> void debug(char *s, T x){
	cerr<< s <<" = "<< x <<endl;
}
template<typename T, typename ...Ar> void debug(char *s, T x, Ar... y){
	int dep = 0;
	while(!(dep == 0 && *s == ',')){
		if(*s == '(') dep++;
		if(*s == ')') dep--;
		cerr << *s++;
	}
	cerr <<" = "<< x <<",";
	debug(s + 1, y...);
}
#define gdb(...) debug((char*)#__VA_ARGS__, __VA_ARGS__)

constexpr int V = 305, T = 1e6;

signed main(){
	#ifdef LOCAL
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<pi> c(m);
	vi mx(V);
	for(auto &[a, b]:c){
		cin >> a >> b;
		chmax(mx[a], b);
	}
	vi f(T);
	rep(i, 1, T - 1){
		rep(j, 1, min(V - 1, i)){
			chmax(f[i], f[i - j + mx[j]] + j);
		}
	}
	int ans = 0;
	rep(i, 1, V - 1){
		int k = i - mx[i];
		int d = max(0ll, n - T + 1);
		int c = (d + k - 1) / k;
		chmax(ans, c * i + f[n - c * k]);
	}
	cout << ans <<'\n';
}

Submission Info

Submission Time
Task G - Get Many Cola
User bananabot
Language C++ 20 (gcc 12.2)
Score 575
Code Size 1511 Byte
Status AC
Exec Time 361 ms
Memory 14236 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 575 / 575
Status
AC × 3
AC × 40
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 02_random2_17.txt, 02_random2_18.txt, 02_random2_19.txt, 02_random2_20.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 03_random3_05.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 273 ms 11004 KiB
00_sample_01.txt AC 280 ms 11064 KiB
00_sample_02.txt AC 275 ms 10836 KiB
01_random_00.txt AC 286 ms 13544 KiB
01_random_01.txt AC 302 ms 13204 KiB
01_random_02.txt AC 344 ms 12844 KiB
01_random_03.txt AC 295 ms 13336 KiB
01_random_04.txt AC 241 ms 13600 KiB
02_random2_00.txt AC 287 ms 14088 KiB
02_random2_01.txt AC 287 ms 14232 KiB
02_random2_02.txt AC 293 ms 14084 KiB
02_random2_03.txt AC 297 ms 14228 KiB
02_random2_04.txt AC 304 ms 14064 KiB
02_random2_05.txt AC 313 ms 14080 KiB
02_random2_06.txt AC 317 ms 14088 KiB
02_random2_07.txt AC 310 ms 14072 KiB
02_random2_08.txt AC 326 ms 14088 KiB
02_random2_09.txt AC 342 ms 14084 KiB
02_random2_10.txt AC 346 ms 14072 KiB
02_random2_11.txt AC 351 ms 14096 KiB
02_random2_12.txt AC 354 ms 14160 KiB
02_random2_13.txt AC 361 ms 14164 KiB
02_random2_14.txt AC 331 ms 14120 KiB
02_random2_15.txt AC 315 ms 14228 KiB
02_random2_16.txt AC 252 ms 14072 KiB
02_random2_17.txt AC 235 ms 14128 KiB
02_random2_18.txt AC 232 ms 14120 KiB
02_random2_19.txt AC 232 ms 14132 KiB
02_random2_20.txt AC 243 ms 14132 KiB
03_random3_00.txt AC 289 ms 14168 KiB
03_random3_01.txt AC 289 ms 14092 KiB
03_random3_02.txt AC 295 ms 14072 KiB
03_random3_03.txt AC 294 ms 14156 KiB
03_random3_04.txt AC 292 ms 14088 KiB
03_random3_05.txt AC 293 ms 14068 KiB
04_handmade_00.txt AC 285 ms 14236 KiB
04_handmade_01.txt AC 286 ms 14028 KiB
04_handmade_02.txt AC 277 ms 10960 KiB
04_handmade_03.txt AC 274 ms 10900 KiB
04_handmade_04.txt AC 291 ms 14176 KiB