文章标题
来源:互联网 发布:网络主播名字大全女 编辑:程序博客网 时间:2024/06/06 00:11
WA
#pragma warning(disable:4996)#include <iostream>#include <cstring>#include<string>#include <cstdio>#include <cmath>#include<algorithm>using namespace std;const int INF = 0x3f3f3f3f;struct{ int cost; string str;}S[100005];int dp[100005];int main(){ int n; loop:while (~scanf("%d", &n)) { int i, j, k; for (i = 1; i <= n; i++) { cin >> S[i].cost; } for (i = 1; i <= n; i++) { cin >> S[i].str; } dp[1] = 0; for (i = 2; i <= n; i++) { string temp, temp1,temp2; temp1 = S[i].str; temp2 = S[i - 1].str; reverse(temp1.begin(), temp1.end()); reverse(temp2.begin(), temp2.end()); temp=S[i - 1].str; if (S[i].str>=S[i - 1].str) { dp[i] = dp[i - 1]; } else if (temp1>= S[i - 1].str || temp2 <= S[i].str) { int s1, s2; s1 = s2 = INF; if (temp1 >= S[i - 1].str) { s1 = S[i].cost; } if (temp2 <= S[i].str) { s2 = S[i - 1].cost; } dp[i] = min(s1, s2); if (dp[i] == s1) { dp[i - 1] = s2; } } else { printf("-1\n"); goto loop; } } cout << dp[n] << endl; }}
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- poj 3281 Dining(网络流)
- 百度面试(数据库隔离级别、overload、override)
- 多线程的编程题目(一)
- listvie y轴 监听滑动距离
- Android studio 中NameValuePair跟BasicNameValuePair 不能正常导包问题
- 文章标题
- viewPager限时滚动
- iOS 开眼效果中的视差效果(UITableViewController)
- JAVA中常说的三大框架指:SSH
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- windows下多线程通信方法
- 强制把系统缓存写入文件sync和fsync函数,, fflush和fsync的联系和区别
- String类,Stringbuilder类,Stringbuffer类之间的区别
- RCNN FastRCNN FasterRCNN 等配置和训练 参考