Skip to content

Commit c6fbcda

Browse files
Michael  ChenMichael  Chen
Michael Chen
authored and
Michael Chen
committed
initial commit
0 parents  commit c6fbcda

File tree

834 files changed

+1229704
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

834 files changed

+1229704
-0
lines changed

.DS_Store

44 KB
Binary file not shown.

.idea/code.iml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/"
6+
}
7+
]
8+
}

222D/.DS_Store

6 KB
Binary file not shown.

222D/222D.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/222D"
6+
}
7+
]
8+
}

222D/ans

33.2 KB
Binary file not shown.

222D/ans.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
7+
#define mp make_pair
8+
#define pb push_back
9+
int nums[100005];
10+
int main() {
11+
#ifdef LOCAL
12+
freopen("input.txt", "r", stdin);
13+
#endif
14+
int n, x;
15+
multiset<int> other;
16+
scanf("%d%d", &n, &x);
17+
for (int i=0; i<2; ++i){
18+
for(int j=0;j<n;++j){
19+
int x; cin >>x;
20+
if (i) nums[j]=x;
21+
else other.insert(x);
22+
}
23+
}
24+
25+
int num=0;
26+
for (int i=0; i<n; ++i) {
27+
int k = x-nums[i];
28+
auto it = other.lower_bound(k);
29+
if (it == other.end()) continue;
30+
++num; other.erase(it);
31+
}
32+
printf("1 %d\n", num);
33+
}

222D/input.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
6 7
2+
4 3 5 6 4 4
3+
8 6 0 4 3 4
4+
5 2
5+
1 1 1 1 1
6+
1 1 1 1 1

242D/.DS_Store

6 KB
Binary file not shown.

242D/242D.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/242D"
6+
}
7+
]
8+
}

242D/ans

63.7 KB
Binary file not shown.

242D/ans.cpp

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
7+
#define mp make_pair
8+
#define pb push_back
9+
10+
const int MAXN= 100005;
11+
vector<vector<int> > adj;
12+
int but[MAXN];
13+
int main() {
14+
#ifdef USE_INPUT_FILE
15+
freopen("input.txt", "r", stdin);
16+
#endif
17+
ios::sync_with_stdio(0);
18+
int N, M;
19+
cin >> N >> M;
20+
adj.resize(N+1);
21+
for (int i=0; i<M; ++i) {
22+
int a, b; cin >> a >> b;
23+
adj[a].pb(b);
24+
adj[b].pb(a);
25+
}
26+
queue<int> q;
27+
vector<int> ans;
28+
for (int i=1; i<=N; ++i) {
29+
cin >> but[i];
30+
if (but[i] == 0) {
31+
q.push(i);
32+
}
33+
}
34+
while (q.size() ) {
35+
int next = q.front(); q.pop();
36+
if (but[next] != 0) continue;
37+
ans.pb(next);
38+
for (int nei : adj[next]) {
39+
// printf("%d %d\n", next, nei);
40+
--but[nei];
41+
if (but[nei] == 0) {
42+
q.push(nei);
43+
}
44+
}
45+
}
46+
47+
cout << ans.size() << '\n';
48+
for (int x : ans) {
49+
cout << x << ' ';
50+
}
51+
cout << '\n';
52+
}

242D/input.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
4 2
2+
1 2
3+
3 4
4+
0 0 0 0
5+
5 5
6+
2 3
7+
4 1
8+
1 5
9+
5 3
10+
2 1
11+
1 1 2 0 2

242D/zzz

63.7 KB
Binary file not shown.

363D/.DS_Store

6 KB
Binary file not shown.

363D/363D.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/363D"
6+
}
7+
]
8+
}

363D/ans

19.3 KB
Binary file not shown.

363D/ans.cpp

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
7+
#define mp make_pair
8+
#define pb push_back
9+
10+
const int MAXN = 100005;
11+
int pers[MAXN];
12+
int cost[MAXN];
13+
int N, M, a;
14+
int s = 0;
15+
bool can(int x) {
16+
vector<int> tp;
17+
for (int i=max(N-x, 0); i<N; ++i) {
18+
tp.pb(pers[i]);
19+
}
20+
int ta = a;
21+
int used = 0;
22+
for (int i=0; i<x; ++i) {
23+
if (cost[i] > tp[i] ){
24+
ta -= (cost[i] - tp[i]);
25+
if (ta < 0) return false;
26+
}
27+
// printf("%d %d %d\n", x, pers[i], cost[i]);
28+
used += min(tp[i], cost[i]);
29+
}
30+
// printf("%d %d %d\n", x, used, ta);
31+
used = max(used-ta, 0);
32+
s = used;
33+
return true;
34+
}
35+
int main() {
36+
#ifdef LOCAL
37+
freopen("input.txt", "r", stdin);
38+
#endif
39+
cin >> N >> M >> a;
40+
for (int i=0; i<N; ++i) {
41+
cin >> pers[i];
42+
}
43+
sort(pers, pers+N);
44+
for(int i=0;i <M; ++i) {
45+
cin >> cost[i];
46+
}
47+
sort(cost, cost+M);
48+
int lb = 0, ub = min(N, M);
49+
while (true) {
50+
if (lb == ub) break;
51+
int xs = (lb+ub+1)/2;
52+
if (can(xs)) {
53+
lb = xs;
54+
}
55+
else ub = xs-1;
56+
}
57+
printf("%d %d\n", lb, s);
58+
}
59+

363D/input.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
5 10 100000
2+
3 1 9 8 3
3+
5 1 7 9 8 9 10 2 3 5 3
4+
5+
9 8 3 3
6+
8 7 3 1
7+
8 7 3 1
8+
4 5 2
9+
8 1 1 2
10+
6 3 7 5 2
11+
2 2 10
12+
5 5
13+
7 6

447D/.DS_Store

6 KB
Binary file not shown.

447D/447D.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/447D"
6+
}
7+
]
8+
}

447D/ans

40.1 KB
Binary file not shown.

447D/ans.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
7+
#define mp make_pair
8+
#define pb push_back
9+
10+
vector<vector<int> > sums;
11+
ll dp[2][(int)1e6+5];
12+
int rows[1005], cols[1005];
13+
int main() {
14+
#ifdef LOCAL
15+
freopen("input.txt", "r", stdin);
16+
#endif
17+
int N, M, K, P;
18+
cin >> N >> M >> K >> P;
19+
sums.resize(2);
20+
for (int i=0; i<N; ++i) {
21+
for (int j=0; j<M; ++j) {
22+
int x; cin >> x;
23+
rows[i] += x;
24+
cols[j] += x;
25+
}
26+
}
27+
for (int i=0; i<N; ++i) sums[0].pb(rows[i]);
28+
for (int i=0;i<M;++i) sums[1].pb(cols[i]);
29+
ll ans = LLONG_MIN;
30+
for (int i=0; i<2; ++i) {
31+
priority_queue<int> pq;
32+
for (int j=0; j<sums[i].size(); ++j) {
33+
pq.push(sums[i][j]);
34+
// cout << sums[i][j]<<endl;
35+
}
36+
// cout << endl;
37+
for (int j=1; j<=K; ++j) {
38+
int x =pq.top();
39+
// cout << "x "<<x << endl;
40+
dp[i][j] = dp[i][j-1] + x;
41+
int ins = x - (i ? N*P : M*P);
42+
// cout << ins << endl;
43+
pq.pop();
44+
pq.push(ins);
45+
}
46+
ans = max(ans, dp[i][K]);
47+
// cout << endl;
48+
}
49+
// cout << ans << endl;
50+
for (int i=1; i<=K; ++i) {
51+
ans = max(ans, dp[0][i] + dp[1][K-i] - 1LL*(K-i)*(i*P));
52+
// printf("%d %d\n", i, ans);
53+
}
54+
cout << ans << endl;
55+
}

447D/input.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
6 3 1000000 100
2+
1 1 1
3+
1 1 1
4+
1 1 1
5+
1 1 1
6+
1 1 1
7+
1 1 1
8+
1 1 2 6
9+
10
10+
11+
2 2 5 2
12+
1 3
13+
2 4
14+
2 2 2 2
15+
1 3
16+
2 4

520D/.DS_Store

6 KB
Binary file not shown.

520D/520D.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/520D"
6+
}
7+
]
8+
}

520D/ans

75 KB
Binary file not shown.

0 commit comments

Comments
 (0)