This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r)
{
return l+rng()%(r-l+1);
}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define forinc(x,a,b) for(int x=a;x<=b;x++)
#define fordec(x,a,b) for(int x=a;x>=b;x--)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ll long long
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define getbit(x,i) ((x>>(i))&1)
#define batbit(x,i) (x|(1ll<<(i)))
#define tatbit(x,i) (x&~(1<<(i)))
#define gg exit(0);
#define int long long
#define ii pair<int,int>
const int N = 2010;
int n , k;
ii a[N];
int f[N][N];
main()
{
fasty;
cin >> n >> k;
forinc(i,1,n)
{
cin >> a[i].fi >> a[i].se;
}
sort(a+1,a+n+1);
if(k==1)
{
memset(f,127,sizeof f);
int ngu=f[0][0];
f[0][0]=0;
forinc(i,0,n)
{
forinc(j,0,n) if(f[i][j] != ngu )
{
if(a[i+1].se>j)
{
f[i+1][j+1] = min(f[i+1][j+1] , f[i][j] + a[i+1].fi);
}
f[i+1][j] = min(f[i+1][j] , f[i][j]);
}
}
fordec(j,n,1)
{
if(f[n][j] != ngu)
{
cout << j <<" "<< f[n][j] << "\n";
return 0;
}
}
}
}
Compilation message (stderr)
Main.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
31 | main()
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |