답안 #141303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
141303 2019-08-07T10:35:54 Z cheetose 스트랩 (JOI14_straps) C++11
100 / 100
183 ms 32004 KB
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

ll d[2002][2002];
Pi p[2002];
int n;
ll go(int N,int k)
{
	if(k<0)return -INF;
	if(N==n)return 0;
	if(k>n)return go(N,n);
	ll &ret=d[N][k];
	if(ret!=-INF-5)return ret;
	ret=0;
	ret=max({ret,go(N+1,k),go(N+1,k+p[N].X)+p[N].Y});
	return ret;
}
int main() {
	fill(&d[0][0],&d[2001][2002],-INF-5);
	scanf("%d",&n);
	fup(i,0,n-1,1)
	{
		scanf("%d%d",&p[i].X,&p[i].Y);
		p[i].X--;
	}
	sort(p,p+n);
	reverse(p,p+n);
	printf("%lld",go(0,1));
}

Compilation message

straps.cpp: In function 'int main()':
straps.cpp:79:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
straps.cpp:82:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&p[i].X,&p[i].Y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 31736 KB Output is correct
2 Correct 27 ms 31736 KB Output is correct
3 Correct 27 ms 31736 KB Output is correct
4 Correct 27 ms 31736 KB Output is correct
5 Correct 27 ms 31708 KB Output is correct
6 Correct 27 ms 31736 KB Output is correct
7 Correct 33 ms 31708 KB Output is correct
8 Correct 27 ms 31732 KB Output is correct
9 Correct 32 ms 31740 KB Output is correct
10 Correct 28 ms 31672 KB Output is correct
11 Correct 27 ms 31736 KB Output is correct
12 Correct 28 ms 31736 KB Output is correct
13 Correct 32 ms 31708 KB Output is correct
14 Correct 27 ms 31736 KB Output is correct
15 Correct 27 ms 31864 KB Output is correct
16 Correct 24 ms 31700 KB Output is correct
17 Correct 27 ms 31736 KB Output is correct
18 Correct 27 ms 31736 KB Output is correct
19 Correct 27 ms 31736 KB Output is correct
20 Correct 27 ms 31736 KB Output is correct
21 Correct 27 ms 31736 KB Output is correct
22 Correct 27 ms 31736 KB Output is correct
23 Correct 28 ms 31740 KB Output is correct
24 Correct 69 ms 31736 KB Output is correct
25 Correct 32 ms 31736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 31740 KB Output is correct
2 Correct 27 ms 31736 KB Output is correct
3 Correct 32 ms 31736 KB Output is correct
4 Correct 32 ms 31736 KB Output is correct
5 Correct 49 ms 31736 KB Output is correct
6 Correct 31 ms 31688 KB Output is correct
7 Correct 27 ms 31736 KB Output is correct
8 Correct 34 ms 31864 KB Output is correct
9 Correct 32 ms 31864 KB Output is correct
10 Correct 33 ms 31736 KB Output is correct
11 Correct 33 ms 31736 KB Output is correct
12 Correct 45 ms 31736 KB Output is correct
13 Correct 47 ms 31864 KB Output is correct
14 Correct 51 ms 31864 KB Output is correct
15 Correct 47 ms 31900 KB Output is correct
16 Correct 46 ms 31864 KB Output is correct
17 Correct 47 ms 31864 KB Output is correct
18 Correct 44 ms 31736 KB Output is correct
19 Correct 92 ms 31864 KB Output is correct
20 Correct 103 ms 31864 KB Output is correct
21 Correct 118 ms 31864 KB Output is correct
22 Correct 49 ms 31864 KB Output is correct
23 Correct 119 ms 31864 KB Output is correct
24 Correct 54 ms 31864 KB Output is correct
25 Correct 114 ms 31736 KB Output is correct
26 Correct 82 ms 31736 KB Output is correct
27 Correct 114 ms 31864 KB Output is correct
28 Correct 80 ms 31736 KB Output is correct
29 Correct 94 ms 31736 KB Output is correct
30 Correct 73 ms 31864 KB Output is correct
31 Correct 73 ms 31912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 31736 KB Output is correct
2 Correct 27 ms 31736 KB Output is correct
3 Correct 28 ms 31632 KB Output is correct
4 Correct 27 ms 31736 KB Output is correct
5 Correct 27 ms 31736 KB Output is correct
6 Correct 27 ms 31736 KB Output is correct
7 Correct 32 ms 31736 KB Output is correct
8 Correct 32 ms 31736 KB Output is correct
9 Correct 32 ms 31784 KB Output is correct
10 Correct 32 ms 31736 KB Output is correct
11 Correct 37 ms 31724 KB Output is correct
12 Correct 36 ms 31736 KB Output is correct
13 Correct 37 ms 31736 KB Output is correct
14 Correct 33 ms 31736 KB Output is correct
15 Correct 32 ms 31736 KB Output is correct
16 Correct 35 ms 31864 KB Output is correct
17 Correct 48 ms 31864 KB Output is correct
18 Correct 47 ms 31992 KB Output is correct
19 Correct 44 ms 31864 KB Output is correct
20 Correct 42 ms 31864 KB Output is correct
21 Correct 62 ms 31736 KB Output is correct
22 Correct 61 ms 31864 KB Output is correct
23 Correct 56 ms 31892 KB Output is correct
24 Correct 47 ms 31736 KB Output is correct
25 Correct 48 ms 31816 KB Output is correct
26 Correct 44 ms 31740 KB Output is correct
27 Correct 41 ms 31736 KB Output is correct
28 Correct 46 ms 31896 KB Output is correct
29 Correct 56 ms 31864 KB Output is correct
30 Correct 50 ms 31864 KB Output is correct
31 Correct 45 ms 31864 KB Output is correct
32 Correct 51 ms 31992 KB Output is correct
33 Correct 40 ms 31836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 31856 KB Output is correct
2 Correct 77 ms 31856 KB Output is correct
3 Correct 72 ms 31992 KB Output is correct
4 Correct 56 ms 31864 KB Output is correct
5 Correct 118 ms 31864 KB Output is correct
6 Correct 129 ms 31864 KB Output is correct
7 Correct 127 ms 31888 KB Output is correct
8 Correct 117 ms 31860 KB Output is correct
9 Correct 118 ms 31864 KB Output is correct
10 Correct 119 ms 31736 KB Output is correct
11 Correct 131 ms 31736 KB Output is correct
12 Correct 183 ms 31896 KB Output is correct
13 Correct 102 ms 31864 KB Output is correct
14 Correct 104 ms 31856 KB Output is correct
15 Correct 121 ms 31888 KB Output is correct
16 Correct 115 ms 31864 KB Output is correct
17 Correct 116 ms 31992 KB Output is correct
18 Correct 117 ms 31864 KB Output is correct
19 Correct 73 ms 31864 KB Output is correct
20 Correct 75 ms 31864 KB Output is correct
21 Correct 74 ms 31864 KB Output is correct
22 Correct 75 ms 31864 KB Output is correct
23 Correct 72 ms 31864 KB Output is correct
24 Correct 73 ms 32004 KB Output is correct
25 Correct 81 ms 31864 KB Output is correct