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 1ada45c

Browse files
Add files via upload
1 parent ce59743 commit 1ada45c

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <cstdio>
2+
3+
#define min(a, b) (a < b ? a : b)
4+
5+
int main()
6+
{
7+
int no_of_elements;
8+
scanf("%d", &no_of_elements);
9+
10+
const int oo = 1e9 + 9;
11+
int sum = 0, min_non_multiple_10 = oo;
12+
13+
while(no_of_elements--)
14+
{
15+
int element;
16+
scanf("%d", &element);
17+
18+
sum += element;
19+
20+
if(element%10 != 0)
21+
min_non_multiple_10 = min(min_non_multiple_10, element);
22+
}
23+
24+
if(sum%10 == 0)
25+
printf("%d\n", min_non_multiple_10 == oo ? 0 : sum - min_non_multiple_10);
26+
else
27+
printf("%d\n", sum);
28+
29+
return 0;
30+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <iostream>
2+
#include <set>
3+
4+
using namespace std;
5+
6+
int main()
7+
{
8+
string S;
9+
cin >> S;
10+
11+
set <char> distinct;
12+
for(int i = 0; i < S.size(); i++)
13+
{
14+
distinct.insert(S[i]);
15+
}
16+
17+
cout << (distinct.size() == S.size() ? "yes" : "no") << "\n";
18+
return 0;
19+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <algorithm>
4+
5+
#define all(v) (v).begin(), (v).end()
6+
typedef long long LL;
7+
using namespace std;
8+
9+
int ceil(LL numerator, LL denominator)
10+
{
11+
int quotient = numerator/denominator;
12+
int remainder_exists = (numerator%denominator != 0);
13+
14+
return (quotient + remainder_exists);
15+
}
16+
17+
int possible(vector <LL> H, LL A, LL B, LL explosions)
18+
{
19+
for(int i = 1; i < H.size(); i++)
20+
{
21+
H[i] -= (explosions*B);
22+
}
23+
24+
LL explosions_used = 0;
25+
for(int i = H.size() - 1; i > 0 && H[i] > 0; i--)
26+
{
27+
explosions_used += ceil(H[i], A - B);
28+
}
29+
30+
return (explosions_used <= explosions);
31+
}
32+
33+
int main()
34+
{
35+
int no_of_monsters, A, B;
36+
cin >> no_of_monsters >> A >> B;
37+
38+
vector <LL> health(no_of_monsters + 1);
39+
for(int i = 1; i <= no_of_monsters; i++)
40+
cin >> health[i];
41+
42+
sort(all(health));
43+
44+
int left_explosions = 1, right_explosions = 1e9;
45+
while(left_explosions <= right_explosions)
46+
{
47+
int mid_explosions = (left_explosions + right_explosions) >> 1;
48+
49+
if(possible(health, A, B, mid_explosions))
50+
{
51+
if(mid_explosions == left_explosions || !possible(health, A, B, mid_explosions - 1))
52+
{
53+
cout << mid_explosions;
54+
break;
55+
}
56+
else
57+
{
58+
right_explosions = mid_explosions - 1;
59+
}
60+
}
61+
else
62+
{
63+
left_explosions = mid_explosions + 1;
64+
}
65+
}
66+
return 0;
67+
}
68+

0 commit comments

Comments
(0)

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