@baobaobear
2020-05-28T09:37:56.000000Z
字数 5468
阅读 157
practise
/*
* @Author: hesorchen
* @Date: 2020-04-14 10:33:26
* @LastEditTime: 2020-05-19 18:01:33
* @Link: https://hesorchen.github.io/
*/
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define endl '\n'
#define PI cos(-1)
#define PB push_back
#define ll long long
#define INF 0x3f3f3f3f
#define mod 998244353
#define lowbit(abcd) (abcd & (-abcd))
#define fre \
{ \
freopen("in.txt", "r", stdin); \
freopen("out.txt", "w", stdout); \
}
int main()
{
int a, b;
cin >> a >> b;
cout << a + b - 1 << endl;
}
/*
* @Author: hesorchen
* @Date: 2020-04-14 10:33:26
* @LastEditTime: 2020-05-19 18:04:16
* @Link: https://hesorchen.github.io/
*/
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define endl '\n'
#define PI cos(-1)
#define PB push_back
#define ll long long
#define INF 0x3f3f3f3f
#define mod 998244353
#define lowbit(abcd) (abcd & (-abcd))
#define fre \
{ \
freopen("in.txt", "r", stdin); \
freopen("out.txt", "w", stdout); \
}
int main()
{
ll n;
cin >> n;
ll ans = 0;
ll s = INF;
while (n--)
{
ll a;
cin >> a;
ans += a;
s = min(s, ans);
}
cout << -s << endl;
}
#include<set>
#include<map>
#include<list>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<algorithm>
#define endl '\n'
#define rtl rt<<1
#define rtr rt<<1|1
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define maxx(a, b) (a > b ? a : b)
#define minn(a, b) (a < b ? a : b)
#define zero(a) memset(a, 0, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define NIL(a) memset(a, -1, sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define _test printf("============\n")
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> P2;
const double pi = acos(-1.0);
const double eps = 1e-7;
const ll MOD = 1000000007LL;
const int INF = 0x3f3f3f3f;
template<typename T> void read(T &x){
x = 0;char ch = getchar();ll f = 1;
while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
const int maxn = 1e2+10;
int arr[maxn];
int main() {
int n;
while(cin>>n && n) {
stack<int> sk;
for (int i = 1; i<=n; ++i) cin >> arr[i];
int p = 1;
for (int i = 1; i<=n; ++i) {
sk.push(i);
while(!sk.empty()&&sk.top()==arr[p]) {
sk.pop(); ++p;
}
}
cout << (p>n?"Yes":"No") << endl;
}
return 0;
}
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int maxn = 2e5 + 5;
const int N = 1e3 + 5;
const int base = 131;
string s1 = "xxxll", s2 = "xxlxll";
int n, t, m;
char s[maxn];
int a[N], sum[N];
int dp[N][2];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
memset(dp,0,sizeof dp);
cin >> s;
int n = strlen(s);
dp[0][1]=1;
for (int i = 0; i < n; i++)
{
if(s[i]>='A'&&s[i]<='Z')
{
dp[i+1][1]=min(dp[i][1]+1,dp[i][0]+2);
dp[i+1][0]=min(dp[i][1]+2,dp[i][0]+2);
}
else
{
dp[i+1][1]=min(dp[i][1]+2,dp[i][0]+2);
dp[i+1][0]=min(dp[i][1]+2,dp[i][0]+1);
}
}
cout<<min(dp[n][1]+1,dp[n][0])<<endl;
}
}
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int maxn = 2e5 + 5;
const int N = 1e3 + 5;
const int base = 131;
string s1 = "xxxll", s2 = "xxlxll";
int n, t, m;
char s[maxn];
int a[N], sum[N];
int dp[N][2];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
ll n, k, c;
cin >> n >> k >> c;
if (k / n * n >= c)
cout << c << endl;
else
cout << n - k / (k / n + 1) + c << endl;
}
#include<set>
#include<map>
#include<list>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<algorithm>
#define endl '\n'
#define rtl rt<<1
#define rtr rt<<1|1
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define maxx(a, b) (a > b ? a : b)
#define minn(a, b) (a < b ? a : b)
#define zero(a) memset(a, 0, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define NIL(a) memset(a, -1, sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define _test printf("============\n")
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> P2;
const double pi = acos(-1.0);
const double eps = 1e-7;
const ll MOD = 1000000007LL;
const int INF = 0x3f3f3f3f;
template<typename T> void read(T &x){
x = 0;char ch = getchar();ll f = 1;
while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
const int maxn = 1e3+10;
char str[maxn];
struct INFO {
ll x, y, z;
bool operator < (const INFO &k) const {
if (x==k.x) return y==k.y ? z>k.z : y<k.y;
return x<k.x;
}
} info[maxn];
vector<INFO> ve;
ll a[3], dp[maxn];
void join() {
sort(a, a+3);
ve.push_back({a[0],a[1],a[2]});
ve.push_back({a[0],a[2],a[1]});
ve.push_back({a[1],a[0],a[2]});
ve.push_back({a[1],a[2],a[0]});
ve.push_back({a[2],a[1],a[0]});
ve.push_back({a[2],a[0],a[1]});
}
int main() {
int n; int kase = 1;
while(~scanf("%d", &n) && n) {
for (int i = 1; i<=n; ++i) {
scanf("%d%d%d", &a[0], &a[1], &a[2]);
join();
}
sort(ve.begin(),ve.end());
//for (int i = 0; i<6*n; ++i) printf("%d %d %d\n", ve[i].x, ve[i].y, ve[i].z);
ll ans = 0;
for (int i = 0; i<6*n; ++i) {
dp[i] = 0;
for (int j = i-1; j>=0; --j)
if (ve[i].x>ve[j].x&&ve[i].y>ve[j].y)
dp[i] = max(dp[i], dp[j]);
//cout << ve[i].z << endl;
dp[i] += ve[i].z;
//cout << dp[i] << endl;
ans = max(ans, dp[i]);
}
printf("Case %d: maximum height = %d\n", kase++, ans);
ve.clear(); zero(dp);
}
return 0;
}