-
Notifications
You must be signed in to change notification settings - Fork 1
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
7 changed files
with
260 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ tmp | |
[0-9]* | ||
i[0-9]* | ||
![0-9]*.cpp | ||
*.txt |
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,47 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mk make_pair | ||
#define fi first | ||
#define se second | ||
|
||
#define MAX 10010 | ||
|
||
typedef long long ll; | ||
typedef pair<int, int> ii; | ||
const int INF = 0x3f3f3f3f; | ||
const double PI = acos(-1.0); | ||
|
||
int main (void) { | ||
ios_base::sync_with_stdio(false); | ||
|
||
int n; | ||
int v[MAX]; | ||
int pd[MAX]; | ||
v[0] = 0; | ||
pd[0] = 0; | ||
|
||
while(scanf("%d", &n) != EOF && n) { | ||
for (int i = 1; i <= n; i++) { | ||
scanf("%d", v + i); | ||
} | ||
|
||
for (int i = 1; i <= n; i++) { | ||
pd[i] = max(v[i], pd[i-1]+v[i]); | ||
} | ||
|
||
int max_pd = *max_element(pd, pd + n + 1); | ||
|
||
if (max_pd > 0) { | ||
printf("The maximum winning streak is %d.\n", max_pd); | ||
} else { | ||
printf("Losing streak.\n"); | ||
} | ||
} | ||
|
||
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,38 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mk make_pair | ||
#define fi first | ||
#define se second | ||
|
||
typedef long long ll; | ||
typedef pair<int, int> ii; | ||
const int INF = 0x3f3f3f3f; | ||
const double PI = acos(-1.0); | ||
|
||
int main (void) { | ||
ios_base::sync_with_stdio(false); | ||
|
||
int v; | ||
int t = 0; | ||
|
||
int notas[] = {50, 10, 5, 1}; | ||
int cedulas[4]; | ||
|
||
while (scanf("%d", &v) != EOF && v != 0) { | ||
for (int i = 0; i < 4; i++) { | ||
cedulas[i] = v / notas[i]; | ||
v -= notas[i] * cedulas[i]; | ||
} | ||
|
||
printf("Teste %d\n", ++t); | ||
printf("%d %d %d %d\n", cedulas[0], cedulas[1], cedulas[2], cedulas[3]); | ||
} | ||
|
||
|
||
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,56 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mk make_pair | ||
#define fi first | ||
#define se second | ||
|
||
#define MAX 6000 | ||
|
||
typedef long long ll; | ||
typedef pair<int, int> ii; | ||
const int INF = 0x3f3f3f3f; | ||
const double PI = acos(-1.0); | ||
|
||
struct pd_struct { | ||
long long with, without; | ||
}; | ||
|
||
int char_to_int(char c) { | ||
return c - '0'; | ||
} | ||
|
||
int main (void) { | ||
ios_base::sync_with_stdio(false); | ||
|
||
char s[MAX]; | ||
pd_struct pd[MAX]; | ||
|
||
int i; | ||
while (true) { | ||
scanf("%s", s); | ||
if(s[0] == '0') break; | ||
|
||
pd[0].with = 0; | ||
pd[0].without = 1; | ||
|
||
for (i = 1; s[i] != '\0'; i++) { | ||
if (s[i-1] == '1' || (s[i-1] == '2' && s[i] <= '6')) | ||
pd[i].with = pd[i-1].without; | ||
else pd[i].with = 0; | ||
|
||
if (s[i] == '0') | ||
pd[i].without = 0; | ||
else | ||
pd[i].without = pd[i-1].with + pd[i-1].without; | ||
} | ||
|
||
printf("%lld\n", pd[i-1].with + pd[i-1].without); | ||
} | ||
|
||
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,52 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mk make_pair | ||
#define fi first | ||
#define se second | ||
|
||
#define MAX 60 | ||
#define MAX_C 1002 | ||
|
||
typedef long long ll; | ||
typedef pair<int, int> ii; | ||
const int INF = 0x3f3f3f3f; | ||
const double PI = acos(-1.0); | ||
|
||
int size[MAX]; | ||
int qtt[MAX]; | ||
long long pd[MAX][MAX_C]; | ||
int f; | ||
|
||
long long calc(int n, int i) { | ||
if (i >= f) return 0; | ||
if (pd[i][n] != -1) return pd[i][n]; | ||
|
||
pd[i][n] = max(n - size[i] >= 0 ? qtt[i] + calc(n-size[i], i+1) : 0, calc(n, i+1)); | ||
|
||
return pd[i][n]; | ||
} | ||
|
||
int main (void) { | ||
ios_base::sync_with_stdio(false); | ||
|
||
int n; | ||
long long t = 0; | ||
while(scanf("%d %d", &n, &f) && (n || f)) { | ||
for (int i = 0; i < f; i++) { | ||
for (int j = 0; j <= n; j++) { | ||
pd[i][j] = -1; | ||
} | ||
|
||
scanf("%d %d", size+i, qtt+i); | ||
} | ||
|
||
printf("Teste %lld\n%lld\n\n", ++t, calc(n, 0)); | ||
} | ||
|
||
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 @@ | ||
https://br.spoj.com/problems/{{problem_id}}/ |
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,65 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mk make_pair | ||
#define fi first | ||
#define se second | ||
|
||
#define MAX 1010 | ||
|
||
typedef long long ll; | ||
typedef pair<int, int> ii; | ||
const int INF = 0x3f3f3f3f; | ||
const double PI = acos(-1.0); | ||
|
||
int pd[MAX]; | ||
int treasure[MAX]; | ||
list<int> parents[MAX]; | ||
int n; | ||
int qt; | ||
int to; | ||
|
||
int calc_pd(int i) { | ||
if (pd[i] == -1) { | ||
int max_treasure = 0; | ||
|
||
for(list<int>::iterator it = parents[i].begin(); it != parents[i].end(); it++) { | ||
max_treasure = max(max_treasure, calc_pd(*it)); | ||
} | ||
|
||
pd[i] = treasure[i] + max_treasure; | ||
} | ||
|
||
return pd[i]; | ||
} | ||
|
||
int main (void) { | ||
ios_base::sync_with_stdio(false); | ||
|
||
while (scanf("%d", &n) != EOF && n) { | ||
for (int i = 1; i <= n; i++) { | ||
parents[i].clear(); | ||
} | ||
|
||
for (int i = 1; i <= n; i++) { | ||
pd[i] = -1; | ||
scanf("%d %d", treasure+i, &qt); | ||
|
||
for (int j = 0; j < qt; j++) { | ||
scanf("%d", &to); | ||
parents[to].push_back(i); | ||
} | ||
} | ||
|
||
for (int i = 1; i <= n; i++) | ||
calc_pd(i); | ||
|
||
printf("%d\n", *max_element(pd+1, pd+n+1)); | ||
} | ||
|
||
return 0; | ||
} | ||
|