Current work
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
3
|
||||
fox box
|
||||
dog cat
|
||||
car bus
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
// ----- FILE IO -----
|
||||
#define STDIN(filename) freopen(filename, "r", stdin)
|
||||
#define STDOUT(filename) freopen(filename, "w", stdout)
|
||||
#define NL '\n'
|
||||
|
||||
// ----- FOR LOOPS -----
|
||||
#define F(i,L,R) for (int i = L; i < R; i++)
|
||||
#define FE(i,L,R) for (int i = L; i <= R; i++)
|
||||
#define FD(i,L,R) for (int i = L; i > R; i--)
|
||||
#define FDE(i,L,R) for (int i = L; i >= R; i--)
|
||||
|
||||
// ----- WEZ -----
|
||||
#define takeI(n) int (n); cin >> n
|
||||
#define takeII(n,m) int (n),(m); cin >> n >> m
|
||||
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
|
||||
#define whileZ takeI(T); while(T--)
|
||||
//
|
||||
// ----- MAX MIN -----
|
||||
#define REMAX(a,b) (a)=max((a),(b))
|
||||
#define REMIN(a,b) (a)=min((a),(b))
|
||||
|
||||
// ----- DEBUG -----
|
||||
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
|
||||
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
|
||||
#define printV(a) printA(a,0,a.size()-1)
|
||||
|
||||
// ----- STL DS
|
||||
#define ALL(c) (c).begin(),(c).end()
|
||||
|
||||
int main() {
|
||||
takeI(n);
|
||||
F(i, 0, n) {
|
||||
}
|
||||
|
||||
int blocksNeeded[26];
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
from collections import Counter
|
||||
|
||||
read = open("blocks.in")
|
||||
n = int(read.readline())
|
||||
blocksNeeded = [0] * 26
|
||||
|
||||
for _ in range(n):
|
||||
a, b = read.readline().split()
|
||||
a, b = Counter(a), Counter(b)
|
||||
for key in a:
|
||||
if key in b:
|
||||
blocksNeeded[ord(key) - ord("a")] += max(a[key], b[key])
|
||||
else:
|
||||
blocksNeeded[ord(key) - ord("a")] += a[key]
|
||||
|
||||
for key in b:
|
||||
if key in a:
|
||||
continue
|
||||
else:
|
||||
blocksNeeded[ord(key) - ord("a")] += b[key]
|
||||
|
||||
with open("blocks.out", "w") as out:
|
||||
for block in blocksNeeded:
|
||||
print(block, file=out)
|
||||
@@ -0,0 +1,4 @@
|
||||
3
|
||||
001
|
||||
111
|
||||
111
|
||||
@@ -0,0 +1,20 @@
|
||||
with open("cowtip.in") as f:
|
||||
n = int(f.readline())
|
||||
grid = [[int(x) for x in line if x.isnumeric()] for line in f.readlines()]
|
||||
|
||||
|
||||
def flip_grid(grid, coord):
|
||||
x, y = coord
|
||||
for i in range(y + 1):
|
||||
for j in range(x + 1):
|
||||
grid[i][j] = int(not grid[i][j])
|
||||
|
||||
|
||||
res = 0
|
||||
for i in range(n - 1, -1, -1):
|
||||
for j in range(n - 1, -1, -1):
|
||||
if grid[i][j] == 1:
|
||||
flip_grid(grid, (j, i))
|
||||
res += 1
|
||||
|
||||
print(res, file=open("cowtip.out", "w"))
|
||||
@@ -0,0 +1,38 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
vector<int> ids(n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
int tmp;
|
||||
cin >> tmp;
|
||||
ids[i] = tmp;
|
||||
}
|
||||
|
||||
int even = 0;
|
||||
int odd = 0;
|
||||
|
||||
for (int id : ids) {
|
||||
if (id % 2 == 0) {
|
||||
even++;
|
||||
} else {
|
||||
odd++;
|
||||
}
|
||||
}
|
||||
|
||||
while (even < odd or even > odd + 1) {
|
||||
if (even < odd) {
|
||||
odd -= 2;
|
||||
even++;
|
||||
} else {
|
||||
even--;
|
||||
}
|
||||
}
|
||||
|
||||
cout << even + odd;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
freopen("paint.in", "r", stdin);
|
||||
freopen("paint.out", "w", stdout);
|
||||
|
||||
int a, b, c, d;
|
||||
cin >> a >> b >> c >> d;
|
||||
|
||||
if (d < a || b < c) {
|
||||
cout << (b - a) + (d - c);
|
||||
} else {
|
||||
cout << abs(max(b, d) - min(a, c));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
7 10
|
||||
4 8
|
||||
@@ -0,0 +1,3 @@
|
||||
7
|
||||
GHHHGHH
|
||||
HHGGGHH
|
||||
@@ -0,0 +1,22 @@
|
||||
# Farmer John orders N cows, of two breeds
|
||||
# H for Holstein or G for Guernsey
|
||||
|
||||
# A string is the breed identifiers John originally wanted
|
||||
# B string is the string when the cows arrive
|
||||
|
||||
read = open("breedflip.in")
|
||||
n = int(read.readline())
|
||||
|
||||
A = read.readline()
|
||||
B = read.readline()
|
||||
|
||||
cnt = 0
|
||||
res = 0
|
||||
for i in range(n):
|
||||
if A[i] != B[i]:
|
||||
cnt += 1
|
||||
elif cnt != 0:
|
||||
cnt = 0
|
||||
res += 1
|
||||
|
||||
print(res, file=open("breedflip.out", "w"))
|
||||
@@ -0,0 +1,15 @@
|
||||
n = int(input())
|
||||
|
||||
xs = [int(x) for x in input().split()]
|
||||
ys = [int(y) for y in input().split()]
|
||||
coords = list(zip(xs, ys))
|
||||
|
||||
maximum_distance = 0
|
||||
for i in range(n - 1):
|
||||
for j in range(i + 1, n):
|
||||
x, y = coords[i]
|
||||
xx, yy = coords[j]
|
||||
distance = (x - xx) * (x - xx) + (y - yy) * (y - yy)
|
||||
maximum_distance = max(distance, maximum_distance)
|
||||
|
||||
print(maximum_distance)
|
||||
@@ -0,0 +1,3 @@
|
||||
10 3
|
||||
11 4
|
||||
12 5
|
||||
@@ -0,0 +1,20 @@
|
||||
read = open("mixmilk.in")
|
||||
|
||||
capacity = [0] * 3
|
||||
milk = [0] * 3
|
||||
|
||||
|
||||
for i in range(3):
|
||||
capacity[i], milk[i] = [int(i) for i in read.readline().split()]
|
||||
|
||||
for i in range(100):
|
||||
curr = i % 3
|
||||
next = (i + 1) % 3
|
||||
if milk[next] + milk[curr] > capacity[next]:
|
||||
milk[curr] = milk[curr] - capacity[next]
|
||||
milk[next] = capacity[next]
|
||||
else:
|
||||
milk[next] = milk[next] + milk[curr]
|
||||
milk[curr] = 0
|
||||
|
||||
print(milk, file=open("mixmilk.out", "w"))
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
freopen("outofplace.in", "r", stdin);
|
||||
size_t n;
|
||||
|
||||
cin >> n;
|
||||
|
||||
vector<int> heights(n);
|
||||
|
||||
for (int &height : heights) {
|
||||
cin >> height;
|
||||
}
|
||||
|
||||
vector<int> sortedHeights(heights);
|
||||
sort(sortedHeights.begin(), sortedHeights.end());
|
||||
|
||||
int bad = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (sortedHeights[i] != heights[i]) {
|
||||
bad++;
|
||||
}
|
||||
}
|
||||
|
||||
freopen("outofplace.out", "w", stdout);
|
||||
cout << bad - 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
6
|
||||
3
|
||||
2
|
||||
4
|
||||
7
|
||||
7
|
||||
9
|
||||
@@ -0,0 +1,53 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
// ----- FILE IO -----
|
||||
#define STDIN(filename) freopen(filename, "r", stdin)
|
||||
#define STDOUT(filename) freopen(filename, "w", stdout)
|
||||
#define NL '\n'
|
||||
|
||||
// ----- FOR LOOPS -----
|
||||
#define F(i,L,R) for (int i = L; i < R; i++)
|
||||
#define FE(i,L,R) for (int i = L; i <= R; i++)
|
||||
#define FD(i,L,R) for (int i = L; i > R; i--)
|
||||
#define FDE(i,L,R) for (int i = L; i >= R; i--)
|
||||
|
||||
// ----- WEZ -----
|
||||
#define takeI(n) int (n); cin >> n
|
||||
#define takeII(n,m) int (n),(m); cin >> n >> m
|
||||
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
|
||||
|
||||
// ----- MAX MIN -----
|
||||
#define REMAX(a,b) (a)=max((a),(b))
|
||||
#define REMIN(a,b) (a)=min((a),(b))
|
||||
|
||||
// ----- DEBUG -----
|
||||
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
|
||||
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
|
||||
#define printV(a) printA(a,0,a.size()-1)
|
||||
|
||||
// ----- STL DS
|
||||
#define ALL(c) (c).begin(),(c).end()
|
||||
|
||||
int main() {
|
||||
STDIN("promote.in");
|
||||
STDOUT("promote.out");
|
||||
|
||||
int bronzeBefore, bronzeAfter, silverBefore, silverAfter, goldBefore, goldAfter, platinumBefore, platinumAfter;
|
||||
cin >> bronzeBefore >> bronzeAfter >> silverBefore >> silverAfter >> goldBefore >> goldAfter >> platinumBefore >> platinumAfter;
|
||||
|
||||
int platinumPromotion, goldPromotion, silverPromotion;
|
||||
|
||||
platinumPromotion = platinumAfter - platinumBefore;
|
||||
|
||||
goldBefore -= platinumPromotion;
|
||||
goldPromotion = goldAfter - goldBefore;
|
||||
|
||||
silverBefore -= goldPromotion;
|
||||
silverPromotion = silverAfter - silverBefore;
|
||||
|
||||
cout << silverPromotion << NL << goldPromotion << NL << platinumPromotion << endl;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
1 2
|
||||
1 1
|
||||
1 1
|
||||
1 2
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
// ----- FILE IO -----
|
||||
#define STDIN(filename) freopen(filename, "r", stdin)
|
||||
#define STDOUT(filename) freopen(filename, "w", stdout)
|
||||
#define NL '\n'
|
||||
|
||||
// ----- FOR LOOPS -----
|
||||
#define F(i,L,R) for (int i = L; i < R; i++)
|
||||
#define FE(i,L,R) for (int i = L; i <= R; i++)
|
||||
#define FD(i,L,R) for (int i = L; i > R; i--)
|
||||
#define FDE(i,L,R) for (int i = L; i >= R; i--)
|
||||
|
||||
// ----- WEZ -----
|
||||
#define takeI(n) int (n); cin >> n
|
||||
#define takeII(n,m) int (n),(m); cin >> n >> m
|
||||
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
|
||||
#define whileZ takeI(T); while(T--)
|
||||
|
||||
// ----- MAX MIN -----
|
||||
#define REMAX(a,b) (a)=max((a),(b))
|
||||
#define REMIN(a,b) (a)=min((a),(b))
|
||||
|
||||
// ----- DEBUG -----
|
||||
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
|
||||
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
|
||||
#define printV(a) printA(a,0,a.size()-1)
|
||||
|
||||
// ----- STL DS
|
||||
#define ALL(c) (c).begin(),(c).end()
|
||||
|
||||
int main() {
|
||||
STDIN("shell.in");
|
||||
STDOUT("shell.out");
|
||||
|
||||
int guesses[4];
|
||||
F(i,0,4) guesses[i] = 0;
|
||||
|
||||
whileZ {
|
||||
takeIII(a,b,g);
|
||||
swap(guesses[a], guesses[b]);
|
||||
guesses[g]++;
|
||||
}
|
||||
|
||||
cout << *max_element(guesses, guesses + 4) << NL;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
3
|
||||
1 2 1
|
||||
3 2 1
|
||||
1 3 1
|
||||
@@ -0,0 +1 @@
|
||||
4 7 9
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
freopen("herding.in", "r", stdin);
|
||||
freopen("herding.out", "w", stdout);
|
||||
|
||||
uint pos[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
cin >> pos[i];
|
||||
}
|
||||
|
||||
sort(pos, pos + 3);
|
||||
uint x = pos[0], y = pos[1], z = pos[2];
|
||||
|
||||
uint minnn = 0;
|
||||
if (z == x + 2) {
|
||||
minnn = 0;
|
||||
} else if (y == x + 2 or z == y + 2) {
|
||||
minnn = 1;
|
||||
} else {
|
||||
minnn = 2;
|
||||
}
|
||||
|
||||
uint maxxx = max(y - x - 1, z - y - 1);
|
||||
|
||||
cout << minnn << '\n' << maxxx << endl;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
freopen("speeding.in", "r", stdin);
|
||||
freopen("speeding.out", "w", stdout);
|
||||
|
||||
int N, M;
|
||||
cin >> N >> M;
|
||||
|
||||
vector<pair<int, int>> speedLimits(N);
|
||||
for (int i = 0; i < N; i++) {
|
||||
int len, speed;
|
||||
cin >> len >> speed;
|
||||
speedLimits[i] = pair<int, int>(len, speed);
|
||||
}
|
||||
|
||||
vector<pair<int, int>> bessieSpeeds(M);
|
||||
for (int i = 0; i < M; i++) {
|
||||
int len, speed;
|
||||
cin >> len >> speed;
|
||||
bessieSpeeds[i] = pair<int, int>(len, speed);
|
||||
}
|
||||
|
||||
int remainingRoad = speedLimits[0].first;
|
||||
int remainingJourney = bessieSpeeds[0].first;
|
||||
int res = 0, j = 0, i = 0;
|
||||
|
||||
while (i < N && j < M) {
|
||||
res = max(res, bessieSpeeds[j].second - speedLimits[i].second);
|
||||
|
||||
int chunk = min(remainingRoad, remainingJourney);
|
||||
remainingRoad -= chunk;
|
||||
remainingJourney -= chunk;
|
||||
|
||||
if (remainingRoad == 0 && ++i < N) {
|
||||
remainingRoad = speedLimits[i].first;
|
||||
}
|
||||
if (remainingJourney == 0 && ++j < M) {
|
||||
remainingJourney = bessieSpeeds[j].first;
|
||||
}
|
||||
}
|
||||
cout << res;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
3 3
|
||||
40 75
|
||||
50 35
|
||||
10 45
|
||||
40 76
|
||||
20 30
|
||||
40 40
|
||||
@@ -0,0 +1,119 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
// ----- FILE IO -----
|
||||
#define STDIN(filename) freopen(filename, "r", stdin)
|
||||
#define STDOUT(filename) freopen(filename, "w", stdout)
|
||||
#define NL '\n'
|
||||
|
||||
// ----- FOR LOOPS -----
|
||||
#define F(i,L,R) for (int i = L; i < R; i++)
|
||||
#define FE(i,L,R) for (int i = L; i <= R; i++)
|
||||
#define FD(i,L,R) for (int i = L; i > R; i--)
|
||||
#define FDE(i,L,R) for (int i = L; i >= R; i--)
|
||||
|
||||
// ----- WEZ -----
|
||||
#define takeI(n) int (n); cin >> n
|
||||
#define takeII(n,m) int (n),(m); cin >> n >> m
|
||||
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
|
||||
#define whileZ takeI(T); while(T--)
|
||||
//
|
||||
// ----- MAX MIN -----
|
||||
#define REMAX(a,b) (a)=max((a),(b))
|
||||
#define REMIN(a,b) (a)=min((a),(b))
|
||||
|
||||
// ----- DEBUG -----
|
||||
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
|
||||
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
|
||||
#define printV(a) printA(a,0,a.size()-1)
|
||||
|
||||
// ----- STL DS
|
||||
#define ALL(c) (c).begin(),(c).end()
|
||||
|
||||
int oneWinner(char** board) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int twoWinner(char** board) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
STDIN("tttt.in");
|
||||
STDOUT("tttt.out");
|
||||
|
||||
char board[3][3];
|
||||
set<char> oneWinner;
|
||||
set<pair<char,char>> twoWinner;
|
||||
|
||||
F(i, 0, 3) {
|
||||
F(j, 0, 3) {
|
||||
cin >> board[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
int res1 = 0, res2 = 0;
|
||||
// rows
|
||||
F(i,0,3) {
|
||||
set<char> s;
|
||||
F(j,0,3) {
|
||||
s.insert(board[i][j]);
|
||||
}
|
||||
if (s.size() == 1) {
|
||||
oneWinner.insert(*s.begin());
|
||||
}
|
||||
if (s.size() == 2) {
|
||||
char a = *s.begin(), b = *next(s.begin());
|
||||
twoWinner.insert(pair(min(a,b), max(a,b)));
|
||||
}
|
||||
}
|
||||
|
||||
// cols
|
||||
F(j,0,3) {
|
||||
set<char> s;
|
||||
F(i,0,3) {
|
||||
s.insert(board[i][j]);
|
||||
}
|
||||
if (s.size() == 1) {
|
||||
oneWinner.insert(*s.begin());
|
||||
}
|
||||
if (s.size() == 2) {
|
||||
char a = *s.begin(), b = *next(s.begin());
|
||||
twoWinner.insert(pair(min(a,b), max(a,b)));
|
||||
}
|
||||
}
|
||||
|
||||
// diags
|
||||
{
|
||||
set<char> s;
|
||||
F(i,0,3) {
|
||||
s.insert(board[i][i]);
|
||||
}
|
||||
if (s.size() == 1) {
|
||||
oneWinner.insert(*s.begin());
|
||||
}
|
||||
if (s.size() == 2) {
|
||||
char a = *s.begin(), b = *next(s.begin());
|
||||
twoWinner.insert(pair(min(a,b), max(a,b)));
|
||||
}
|
||||
}
|
||||
{
|
||||
set<char> s;
|
||||
F(i,0,3) {
|
||||
s.insert(board[2-i][i]);
|
||||
}
|
||||
if (s.size() == 1) {
|
||||
oneWinner.insert(*s.begin());
|
||||
}
|
||||
if (s.size() == 2) {
|
||||
char a = *s.begin(), b = *next(s.begin());
|
||||
twoWinner.insert(pair(min(a,b), max(a,b)));
|
||||
}
|
||||
}
|
||||
cout << oneWinner.size() << NL;
|
||||
cout << twoWinner.size();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
COW
|
||||
XXO
|
||||
ABC
|
||||
@@ -0,0 +1,37 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
freopen("shuffle.in", "r", stdin);
|
||||
freopen("shuffle.out", "w", stdout);
|
||||
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
vector<int> unshuffle(n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
int tmp;
|
||||
cin >> tmp;
|
||||
unshuffle[i] = tmp - 1;
|
||||
}
|
||||
|
||||
vector<int> ids(n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
cin >> ids[i];
|
||||
}
|
||||
|
||||
vector<int> tmp(n);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
tmp[j] = ids[unshuffle[j]];
|
||||
}
|
||||
swap(tmp, ids);
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
cout << ids[i] << '\n';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
5
|
||||
1 3 4 5 2
|
||||
1234567 2222222 3333333 4444444 5555555
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
3
|
||||
4 10 1
|
||||
8 13 3
|
||||
2 6 2
|
||||
@@ -0,0 +1,27 @@
|
||||
// #include "../../debugging.h"
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
freopen("blist.in", "r", stdin);
|
||||
freopen("blist.out", "w", stdout);
|
||||
|
||||
int n, res = 0;
|
||||
cin >> n;
|
||||
|
||||
vector<int> bucketsAtTimeT(1000);
|
||||
for (int i = 0; i < n; i++) {
|
||||
int s, t, b;
|
||||
cin >> s >> t >> b;
|
||||
|
||||
for (int j = s; j <= t; j++) {
|
||||
bucketsAtTimeT[j] += b;
|
||||
res = max(res, bucketsAtTimeT[j]);
|
||||
}
|
||||
}
|
||||
|
||||
cout << res;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
n, k = [int(x) for x in input().split()]
|
||||
days = [int(x) - 1 for x in input().split()]
|
||||
|
||||
res = k + 1
|
||||
prev = days[0]
|
||||
|
||||
for day in days[1:]:
|
||||
res = min(res + 1 + k, res + (day - prev))
|
||||
prev = day
|
||||
|
||||
print(res)
|
||||
Reference in New Issue
Block a user