add@scpc 2025-1s

This commit is contained in:
2025-07-13 16:14:31 +09:00
parent 9d56695b0c
commit a079f8652b
4 changed files with 252 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
#include <iostream>
#include <vector>
using namespace std;
long long minimum_total_movement_length(
int n, int reds,
const vector<int> &pos_blue_houses, const vector<int> &pos_red_houses, const vector<int> &pos_blue_shops, const vector<int> &pos_red_shops
) {
long long cost = 0;
pos_red_houses
return cost;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
for (auto test_case = 1; test_case <= t; test_case++) {
int n, reds;
cin >> n >> reds;
vector<int> pos_blue_houses(n - reds), pos_red_houses(reds), pos_blue_shops(n - reds - 1), pos_red_shops(reds + 1);
for (auto i = 0; i < n - reds; i++) { cin >> pos_blue_houses[i]; }
for (auto i = 0; i < reds; i++) { cin >> pos_red_houses[i]; }
for (auto i = 0; i < n - reds - 1; i++) { cin >> pos_blue_shops[i]; }
for (auto i = 0; i < reds + 1; i++) { cin >> pos_red_shops[i]; }
cout << "Case #" << test_case << endl;
cout << minimum_total_movement_length(n, reds, pos_blue_houses, pos_red_houses, pos_blue_shops, pos_red_shops) << endl;
}
}

View File

@@ -0,0 +1,80 @@
#include <iostream>
#include <vector>
using namespace std;
int max_customs_sold(const vector<int> &arr) {
int num500 = 0;
int num1000 = 0;
int num5000 = 0;
int cnt = 0;
for (int e: arr) {
if (e == 500) {
num500++;
cnt++;
} else if (e == 1000) {
if (num500 >= 1) {
num1000++;
num500--;
cnt++;
} else { break; }
} else {
if (num1000 >= 4 && num500 >= 1) {
num5000++;
num1000 -= 4;
num500--;
cnt++;
} else if (num1000 >= 3 && num500 >= 3) {
num5000++;
num1000 -= 3;
num500 -= 3;
cnt++;
} else if (num1000 >= 2 && num500 >= 5) {
num5000++;
num1000 -= 2;
num500 -= 5;
cnt++;
} else if (num1000 >= 1 && num500 >= 7) {
num5000++;
num1000 -= 1;
num500 -= 7;
cnt++;
} else if (num500 >= 9) {
num5000++;
num500 -= 9;
cnt++;
} else {
break;
}
}
}
return cnt;
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
cin >> t;
for (int test_case = 1; test_case <= t; test_case++) {
int n;
cin >> n;
vector<int> v;
for (int j = 0; j < n; j++) {
int x;
cin >> x;
v.push_back(x);
}
cout << "Case #" << test_case << endl;
cout << max_customs_sold(v) << endl;
}
return 0;
}

View File

@@ -0,0 +1,37 @@
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
long long total_legal_minimum_length(int length, vector<int> pos) {
long long legal_length = pos[0];
for (auto i = 0; i < pos.size() - 1; i++) { legal_length += min(pos[i] + pos[i + 1], length - pos[i] + length - pos[i + 1]); }
legal_length += min(length - pos[pos.size() - 1], pos[pos.size() - 1]);
return legal_length;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
size_t t;
cin >> t;
for (auto test_case = 1; test_case <= t; test_case++) {
int n, l;
cin >> n >> l;
int tmp;
vector<int> p;
for (auto i = 0; i < n; i++) {
cin >> tmp;
p.push_back(tmp);
}
cout << "Case #" << test_case << endl;
cout << total_legal_minimum_length(l, p) << endl;
}
}

View File

@@ -0,0 +1,93 @@
#include <iostream>
using namespace std;
constexpr long long MOD = 1000000007;
int POW3[100001];
int get_count_decimal_012(const string &s) {
auto n = s.size();
if (n == 1) { if (s[0] == '1') { return 1; } else { return 2; } }
auto cnt = 0LL;
// f (1 until 10^(n-1))을 구하기
auto temp = 1LL;
POW3[0] = temp;
for (auto i = 1; i <= (n - 1); i++) {
temp *= 3;
temp %= MOD;
POW3[i] = temp;
}
temp += MOD - 1;
temp %= MOD;
cnt += temp;
cnt %= MOD;
// f(10^(n-1) to int(s)) 까지 구하기
if (s[0] == '0') {
// pass
} else if (s[0] == '1') {
// pass
} else if (s[0] == '2') {
long long tmpx = POW3[n - 1];
cnt += tmpx;
cnt %= MOD;
} else {
long long tmpx = POW3[n - 1];
tmpx *= 2;
cnt += tmpx;
cnt %= MOD;
return static_cast<int>(cnt);
}
bool flag = false;
for (int i = 1; i < n; i++) {
auto ch = s[i];
if (ch == '0') { continue; } else if (ch == '1') {
long long tmpx = POW3[n - i - 1];
cnt += tmpx;
cnt %= MOD;
} else if (ch == '2') {
long long tmpx = 2 * POW3[n - i - 1];
cnt += tmpx;
cnt %= MOD;
} else {
long long tmpx;
tmpx = POW3[n - i];
cnt += tmpx;
cnt %= MOD;
flag = true;
break;
}
}
if (!flag) {
cnt++;
cnt %= MOD;
}
return static_cast<int>(cnt);
}
int main() {
ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
cin >> t;
for (auto test_case = 1; test_case <= t; test_case++) {
string s;
cin >> s;
cout << "Case #" << test_case << endl;
cout << get_count_decimal_012(s) << endl;
}
}