#include<bits/stdc++.h> using namespace std; int t,m; int x,y,b[105],c[1005]={}; int main() { cin>>t>>m; for(int k=1;k<=m;k++) { cin>>x>>y; for(int z=t;z>=x;z--) { c[z]=max(c[z-1],c[z-x]+y); } } cout<<c[t]; }
#1#2#3AC,其他WA