Skip to content

Commit c78543b

Browse files
committed
SCPC diet solve
1 parent 45e415a commit c78543b

File tree

7 files changed

+180
-0
lines changed

7 files changed

+180
-0
lines changed

SCPC/card_game/card_game.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
You should use the standard input/output
3+
4+
in order to receive a score properly.
5+
6+
Do not use file input and output
7+
8+
Please be very careful.
9+
*/
10+
11+
#include <iostream>
12+
13+
using namespace std;
14+
15+
int Answer;
16+
17+
int main(int argc, char** argv)
18+
{
19+
int T, test_case;
20+
/*
21+
The freopen function below opens input.txt file in read only mode, and afterward,
22+
the program will read from input.txt file instead of standard(keyboard) input.
23+
To test your program, you may save input data in input.txt file,
24+
and use freopen function to read from the file when using cin function.
25+
You may remove the comment symbols(//) in the below statement and use it.
26+
Use #include<cstdio> or #include <stdio.h> to use the function in your program.
27+
But before submission, you must remove the freopen function or rewrite comment symbols(//).
28+
*/
29+
30+
// freopen("input.txt", "r", stdin);
31+
32+
cin >> T;
33+
for(test_case = 0; test_case < T; test_case++)
34+
{
35+
36+
Answer = 0;
37+
/////////////////////////////////////////////////////////////////////////////////////////////
38+
/*
39+
Implement your algorithm here.
40+
The answer to the case will be stored in variable Answer.
41+
*/
42+
/////////////////////////////////////////////////////////////////////////////////////////////
43+
44+
// Print the answer to standard output(screen).
45+
cout << "Case #" << test_case+1 << endl;
46+
cout << Answer << endl;
47+
}
48+
49+
return 0;//Your program should return 0 on normal termination.
50+
}

SCPC/card_game/input

Whitespace-only changes.

SCPC/diet/diet.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
You should use the standard input/output
3+
4+
in order to receive a score properly.
5+
6+
Do not use file input and output
7+
8+
Please be very careful.
9+
*/
10+
11+
#include <iostream>
12+
#include <algorithm>
13+
using namespace std;
14+
15+
int A[200001];
16+
int B[200001];
17+
int Answer;
18+
19+
int max(int a, int b){return (a>b?a:b);}
20+
21+
int get_cal(int N, int K){
22+
int result = 0;
23+
sort(A, A+N);
24+
sort(B, B+N);
25+
26+
for(int i =0; i<K; ++i){
27+
result = max(result, A[i] + B[K-i-1]);
28+
}
29+
30+
return result;
31+
}
32+
33+
int main(int argc, char** argv)
34+
{
35+
int T, test_case;
36+
/*
37+
The freopen function below opens input.txt file in read only mode, and afterward,
38+
the program will read from input.txt file instead of standard(keyboard) input.
39+
To test your program, you may save input data in input.txt file,
40+
and use freopen function to read from the file when using cin function.
41+
You may remove the comment symbols(//) in the below statement and use it.
42+
Use #include<cstdio> or #include <stdio.h> to use the function in your program.
43+
But before submission, you must remove the freopen function or rewrite comment symbols(//).
44+
*/
45+
46+
// freopen("input.txt", "r", stdin);
47+
48+
cin >> T;
49+
for(test_case = 0; test_case < T; ++test_case)
50+
{
51+
52+
Answer = 0;
53+
54+
int N, K;
55+
56+
cin >> N >> K;
57+
58+
for(int i =0; i<N; ++i){
59+
cin >> A[i];
60+
}
61+
for(int i = 0; i<N; ++i){
62+
cin >> B[i];
63+
}
64+
Answer = get_cal(N, K);
65+
66+
67+
cout << "Case #" << test_case+1 << endl;
68+
cout << Answer << endl;
69+
}
70+
71+
return 0;//Your program should return 0 on normal termination.
72+
}

SCPC/diet/input

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2
2+
2 2
3+
1 2
4+
4 2
5+
3 2
6+
6 3 1
7+
1 4 3
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
5+
char comp[10];
6+
bool check[10];
7+
int k;
8+
9+
void max(){
10+
11+
for(int i =0; i<k; ++i){
12+
13+
if(comp[i] == '>'){
14+
15+
}
16+
17+
18+
}
19+
20+
}
21+
void min(){
22+
23+
}
24+
25+
int main(){
26+
27+
cin >> k;
28+
29+
for(int i =0; i<k; ++i){
30+
31+
cin >> comp[i];
32+
}
33+
34+
35+
36+
37+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
3+
4+
5+
6+
//https://joonas.tistory.com/25
7+
//https://www.crocus.co.kr/1232
8+
//https://core-research-team.github.io/?fbclid=IwAR1YCD3yHKvkAkJncpW-JRPS52MlbtMWFeFJWlXqMzCi5LMZkbZvyC69m2k
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
10 12 3 9
3+
10 12 10 12
4+
13 11 5 6
5+
15 13 2 4
6+
40000 39999 40000 39999

0 commit comments

Comments
 (0)