-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <iostream> | ||
#include <unordered_set> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
ios_base::sync_with_stdio(false); | ||
cin.tie(nullptr); | ||
|
||
string s; | ||
cin >> s; | ||
|
||
if (unordered_set<char>(s.begin(), s.end()).size() == 1) { | ||
cout << "-1"; | ||
return 0; | ||
} | ||
|
||
auto isPalindrome = [](string &s) { | ||
int lo = 0; | ||
int hi = s.size() - 1; // NOLINT | ||
|
||
while (lo < hi) { | ||
if (s[lo] != s[hi]) return false; | ||
lo++; | ||
hi--; | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
if (!isPalindrome(s)) { | ||
cout << s.size(); | ||
return 0; | ||
} | ||
|
||
cout << s.size() - 1; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from itertools import permutations | ||
|
||
stdin = open(0) | ||
|
||
L, N = map(int, stdin.readline().split()) | ||
words = sorted(stdin.read().splitlines()) | ||
|
||
# ๋จ์ด ์์ด x๊ฐ ๋จ์ด ๋ง๋ฐฉ์ง์ธ์ง ํ์ธํ๋ ํจ์ | ||
def isValid(x): | ||
for i in range(L): | ||
for j in range(L): | ||
if x[i][j] != x[j][i]: return False | ||
|
||
return True | ||
|
||
for perm in permutations(words, L): | ||
if not isValid(perm): continue | ||
|
||
print(*perm, sep='\n') | ||
exit() | ||
|
||
print('NONE') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
total_app_count, need_memory = map(int,input().split()) | ||
|
||
use_memory = list(map(int,input().split())) | ||
re_use_cost = list(map(int,input().split())) | ||
|
||
dp_table = [0 for _ in range(sum(re_use_cost)+1)] | ||
cost_sum = sum(re_use_cost) | ||
|
||
for memory, cost in zip(use_memory, re_use_cost): | ||
for idx in range(cost_sum,cost-1,-1): | ||
dp_table[idx] = max(dp_table[idx], dp_table[idx-cost] + memory) | ||
|
||
for idx, memory in enumerate(dp_table): | ||
if memory >= need_memory: | ||
print(idx) | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import sys | ||
|
||
remain_days, need_score = map(int,sys.stdin.readline().split()) | ||
volunteer_scores = [0] | ||
volunteer_scores.extend(list(map(int,sys.stdin.readline().split()))) | ||
|
||
blood_donation_score, blood_donation_break_time = map(int,sys.stdin.readline().split()) | ||
|
||
volunteer_scores.extend([0 for _ in range(blood_donation_break_time-1)]) | ||
maximum_blood_donation_count = (len(volunteer_scores)+blood_donation_break_time-1)//blood_donation_break_time+1 | ||
|
||
dp_table = [[0 for _ in range(maximum_blood_donation_count)] for _ in range(len(volunteer_scores))] | ||
|
||
for date in range(len(volunteer_scores)): | ||
if date >= blood_donation_break_time: | ||
for blood_donation_count in range(1,maximum_blood_donation_count): | ||
dp_table[date][blood_donation_count] = max(dp_table[date][blood_donation_count], | ||
dp_table[date-1][blood_donation_count] + volunteer_scores[date], | ||
dp_table[date-blood_donation_break_time][blood_donation_count-1] + blood_donation_score) | ||
|
||
dp_table[date][0] = dp_table[date-1][0] + volunteer_scores[date] | ||
|
||
print(dp_table) | ||
|
||
for count in range(len(dp_table[-1])): | ||
if dp_table[-1][count] >= need_score: | ||
print(count) | ||
break | ||
|
||
else: print(-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
target = int(input()) | ||
|
||
M = 1_000_000 | ||
period = 1_500_000 | ||
|
||
target %= period | ||
|
||
dp_table = [0 for _ in range(3)] | ||
dp_table[0] = 0 | ||
dp_table[1] = 1 | ||
|
||
for idx in range(2,target+1): | ||
idx %= 3 | ||
dp_table[idx] = dp_table[idx-1] % M + dp_table[idx-2] % M | ||
|
||
print(dp_table[target%3]%M) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import sys | ||
input=sys.stdin.readline | ||
|
||
n,x=map(int,input().split()) | ||
data=list(map(int,input().split())) | ||
|
||
if max(data) == 0: | ||
print("SAD") | ||
else: | ||
value = sum(data[:x]) # x๊ฐ์ฉ ์๋์ฐ ์์ฑ | ||
max_value=value | ||
max_cnt=1 | ||
|
||
for i in range(x,n): | ||
value+=data[i] | ||
value-=data[i-x] | ||
|
||
if value > max_value: | ||
max_value=value | ||
max_cnt =1 | ||
|
||
elif value == max_value: | ||
max_cnt+=1 | ||
|
||
print(max_value) | ||
print(max_cnt) |