main
黄海 1 year ago
parent 79aa3d9ae7
commit d831152b3e

@ -3,8 +3,8 @@
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 110;
int n; //电桩数
int d; //冲一次电能跑的距离
int n; // 电桩数
int d; // 冲一次电能跑的距离
int res = INF;
int a[N];
/*
@ -20,9 +20,18 @@ void dfs(int u, int r, int c) {
res = min(res, c);
return;
}
if (r + d >= a[u + 1]) dfs(u + 1, r + d - a[u + 1], c + 1);
// 现在剩余的油量是r,加满的话油量是d
// 如果现在剩余的油量r不足以跑完下一个路a[u+1],那么必须在本站加油到d
if (d < a[u + 1]) {
cout << -1 << endl;
exit(0);
}
if (r >= a[u + 1]) dfs(u + 1, r - a[u + 1], c);
if (r >= a[u + 1]) { // 我有两种选择1、在本站不加油2、我就加满
dfs(u + 1, r - a[u + 1], c);
dfs(u + 1, d - a[u + 1], c + 1);
} else
dfs(u + 1, d - a[u + 1], c + 1);
}
int main() {
cin >> n >> d;

@ -1,22 +1,30 @@
#include <bits/stdc++.h>
using namespace std;
int k;
string kill(string s) {
int p = 0;
for (int i = 0; i < s.size() - 1; i++)
if (s[i + 1] > s[i]) {
p = i;
break;
}
string res;
for (int i = 0; i < s.size(); i++)
if (i != p) res += s[i];
return res;
}
const int N = 110;
struct Node {
int id;
int score;
const bool operator<(const Node &t) {
if (score == t.score) return id < t.id;
return score > t.score;
}
} a[N];
/*
3
3 84
1 87
2 84
*/
int main() {
string s;
cin >> s >> k;
for (int i = 1; i <= k; i++) s = kill(s);
cout << s;
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].id >> a[i].score;
sort(a + 1, a + 1 + n);
for (int i = 1; i <= n; i++)
cout << a[i].id << " " << a[i].score << endl;
return 0;
}
}

@ -0,0 +1,21 @@
#include <bits/stdc++.h>
using namespace std;
const int N=110;
struct Node {
int id;
int fen;
bool operator<(const Node &t) {
if (fen == t.fen) return id < t.id;
return fen > t.fen;
}
} a[N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i].id >> a[i].fen;
sort(a+1, a + n+1);
for (int i = 1; i <= n; i++) cout << a[i].id << " " << a[i].fen << endl;
return 0;
}
Loading…
Cancel
Save