Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c858210

Browse files
committed
Today ps
1 parent b8d5235 commit c858210

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

‎Baekjoon/Cpp/1049.cpp‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <bits/stdc++.h>
2+
#define MAX 2147483647
3+
#define UNIT 6
4+
5+
using namespace std;
6+
7+
int main()
8+
{
9+
ios::sync_with_stdio(false);
10+
cin.tie(nullptr);
11+
cout.tie(nullptr);
12+
int n, m, a, b, d, one = MAX, six = MAX;
13+
cin >> n >> m;
14+
d = n / UNIT;
15+
while (m--)
16+
{
17+
cin >> a >> b;
18+
one = min(one, b);
19+
six = min(six, a);
20+
}
21+
six = min(six, one * UNIT);
22+
if (n % UNIT == 0)
23+
{
24+
cout << d * six;
25+
}
26+
else
27+
{
28+
cout << min(d * six + (n % UNIT) * one, (d + 1) * six);
29+
}
30+
return 0;
31+
}

‎Baekjoon/Cpp/1449.cpp‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
bool marked[2001];
6+
7+
int main()
8+
{
9+
ios::sync_with_stdio(false);
10+
cin.tie(nullptr);
11+
cout.tie(nullptr);
12+
int n, l, i, j, res = 0;
13+
cin >> n >> l;
14+
int arr[n];
15+
for (i = 0; i < n; i++)
16+
{
17+
cin >> arr[i];
18+
}
19+
sort(arr, arr + n);
20+
for (i = 0; i < n; i++)
21+
{
22+
cin >> arr[i];
23+
if (marked[arr[i]])
24+
{
25+
continue;
26+
}
27+
for (j = arr[i]; j < arr[i] + l; j++)
28+
{
29+
marked[j] = true;
30+
}
31+
res += 1;
32+
}
33+
cout << res;
34+
return 0;
35+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /