Submission #1794764
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dy[] = { 0, 0, 1, -1 };
int dx[] = { 1, -1, 0, 0 };
ll A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z;
namespace arc009a {
void arc009a();
}
namespace arc004b {
void arc004b();
}
int main()
{
arc009a::arc009a();
return 0;
}
template <typename T>
vector<T> INP(ll n)
{
vector<T> x;
REP(i, n) {
T tmp; cin >> tmp;
x.push_back(tmp);
}
return move(x);
}
//* n文字1行の文字列を入力,一文字ごとの配列を返す
vector<char> SPRIT_STRING(ll n)
{
string str; cin >> str;
vector<char> cs(n);
REP(i, n) cs[i] = str[i];
return move(cs);
}
//* 文字列中から文字列を検索して別の文字列に置換する
void strReplace(std::string& str, const std::string& from, const std::string& to) {
std::string::size_type pos = 0;
while (pos = str.find(from, pos), pos != std::string::npos) {
str.replace(pos, from.length(), to);
pos += to.length();
}
}
// unsolved
namespace arc002c {
void arc002c()
{
cin >> N;
string cmd; cin >> cmd;
map<string, ll> nums;
REP(i, cmd.size() - 1) {
string two = cmd.substr(i, 2);
if (nums.find(two) != nums.end())
nums[two]++;
else
nums[two] = 1;
}
vector< pair<int, string> > clist;
for (auto n : nums) {
clist.push_back(make_pair(n.second, n.first));
}
sort(clist.begin(), clist.end());
strReplace(cmd, clist[clist.size() - 1].second, "L");
map<string, ll> numsL;
int cnt = 0;
REP(i, cmd.size() - 1) {
string two = cmd.substr(i, 2);
if (two[0] == 'L' or two[1] == 'L') continue;
if (numsL.find(two) != numsL.end())
numsL[two]++;
else {
numsL[two] = 1;
cnt++;
}
}
if (cnt == 0) {
cout << cmd.size() << endl;
return;
}
vector< pair<int, string> > clist1;
for (auto n : numsL) {
clist1.push_back(make_pair(n.second, n.first));
}
sort(clist1.begin(), clist1.end());
strReplace(cmd, clist1[clist1.size() - 1].second, "R");
cout << cmd.size() << endl;
}
}
// solved
//
namespace arc009a {
void arc009a()
{
cin >> N;
double cost = 0;
REP(i, N) {
int a, b; cin >> a >> b;
cost += a * b;
}
cout << (int)(cost*1.05) << endl;
}
}
namespace arc008a {
void arc008a()
{
string str; cin >> str;
int cost = 0;
if (str.size() == 2) {
int one = (int)str[0] - (int)'0';
cost += one * 100;
str[0] = str[1];
}
if (str[0] > '6')
cost += 100;
else
cost += (str[0] - '0') * 15;
cout << cost << endl;
}
}
namespace arc004b {
void arc004b()
{
cin >> N;
vector<int> ds(N);
for (auto& d : ds) cin >> d;
int maxD = *max_element(ds.begin(), ds.end());
int sum = accumulate(ds.begin(), ds.end(), 0);
cout << sum << endl;
int rest = sum - maxD;
if (rest < maxD)
cout << maxD - rest << endl;
else
cout << 0 << endl;
}
}
namespace arc007a {
void arc007a()
{
char b; cin >> b;
string str; cin >> str;
for (auto s : str)
if (s != b)
cout << s;
cout << endl;
}
}
namespace arc006a{
void arc006a()
{
set<int> es;
REP(i, 6) {
int x; cin >> x;
es.insert(x);
}
cin >> B;
bool bonus = false;
int cnt = 0;
REP(i, 6) {
int l; cin >> l;
if (l == B)
bonus = true;
if (es.find(l) != es.end())
cnt++;
}
if (cnt < 3)
cout << 0 << endl;
else if (cnt == 6)
cout << 1 << endl;
else if (cnt == 5)
if (bonus)
cout << 2 << endl;
else
cout << 3 << endl;
else if (cnt == 4)
cout << 4 << endl;
else
cout << 5 << endl;
}
}
namespace arc003b {
void arc003b()
{
cin >> N;
vector< pair<string, string> > strs(N);
REP(i, N) {
string str; cin >> str;
strs[i].second = str;
strs[i].first = string(str.rbegin(), str.rend());
}
sort(strs.begin(), strs.end());
for (auto s : strs) {
cout << s.second << endl;
}
}
}
namespace arc005a {
void arc005a()
{
cin >> N;
ll cnt = 0;
REP(i, N) {
string str; cin >> str;
if (str[str.size() - 1] == '.')
str = str.substr(0, str.size() - 1);
if (str == string("TAKAHASHIKUN") or
str == string("Takahashikun") or
str == string("takahashikun"))
cnt++;
}
cout << cnt << endl;
}
}
namespace arc004a {
void arc004a()
{
cin >> N;
vector<int> xs(N), ys(N);
REP(i, N) cin >> xs[i] >> ys[i];
int maxDist = 0;
REP(i, N) REP(j, N) {
if (i == j) continue;
int xdiff = abs(xs[i] - xs[j]);
int ydiff = abs(ys[i] - ys[j]);
maxDist = max(maxDist, xdiff*xdiff + ydiff*ydiff);
}
cout << sqrt(maxDist) << endl;
}
}
namespace arc003a {
void arc003a()
{
cin >> N;
vector<char> rs = SPRIT_STRING(N);
ll score = 0;
for (auto r : rs)
switch (r)
{
case 'A': score += 4; break;
case 'B': score += 3; break;
case 'C': score += 2; break;
case 'D': score += 1; break;
default: break;
}
cout << fixed << setprecision(10) << ((double)score / (double)N) << endl;
}
}
namespace arc002b {
bool isUruu(ll year)
{
return (year % 4 == 0 && year % 100 != 0 || year % 400 == 0);
}
pair<int, pair<int, int>> nextDay(int y, int m, int d)
{
int lastDay;
if (m == 2)
if (isUruu(y))
lastDay = 29;
else
lastDay = 28;
else if (m == 4 or m == 6 or m == 9 or m == 11)
lastDay = 30;
else
lastDay = 31;
int nextDay = d + 1;
int nextMonth = m;
int nextYear = y;
if (nextDay > lastDay) {
nextDay = 1;
nextMonth++;
if (nextMonth > 12) {
nextMonth = 1;
nextYear++;
}
}
return make_pair(nextYear, make_pair(nextMonth, nextDay));
}
void arc002b()
{
string str; cin >> str;
auto next = make_pair(stoi(str.substr(0, 4)), make_pair(stoi(str.substr(5, 2)), stoi(str.substr(8, 2))));
while (true) {
double s = (double)next.first / (double)next.second.first / (double)next.second.second;
double cs = (double)( (int)s );
if (s == cs) break;
next = nextDay(next.first, next.second.first, next.second.second);
}
string oy = to_string(next.first);
string om = to_string(next.second.first); if (om.size() == 1) om = string("0") + om;
string od = to_string(next.second.second); if (od.size() == 1) od = string("0") + od;
cout << oy << "/" << om << "/" << od << endl;
}
}
namespace arc001b {
void arc001b()
{
cin >> A >> B;
ll current = A;
int cnt = 0;
while (current != B) {
ll diff = B - current;
ll dir = 1;
if (diff < 0) dir = -1;
ll d1 = abs(B - (current + dir * 1));
ll d5 = abs(B - (current + dir * 5));
ll d10 = abs(B - (current + dir * 10));
if (d10 <= min(d1, d5)) {
current += dir * 10;
}
else if (d5 <= d1) {
current += dir * 5;
}
else {
current += dir * 1;
}
cnt++;
}
cout << cnt << endl;
return;
}
}
Submission Info
Submission Time |
|
Task |
A - 元気にお使い!高橋君 |
User |
xoke |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
7195 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
00_sample1.txt, 00_sample2.txt, 00_sample3.txt, 00_sample4.txt, 01_rand_00.txt, 01_rand_01.txt, 01_rand_02.txt, 01_rand_03.txt, 01_rand_04.txt, 01_rand_05.txt, 01_rand_06.txt, 01_rand_07.txt, 01_rand_08.txt, 01_rand_09.txt, 01_rand_10.txt, 01_rand_11.txt, 01_rand_12.txt, 01_rand_13.txt, 01_rand_14.txt, 01_rand_15.txt, 01_rand_16.txt, 01_rand_17.txt, 01_rand_18.txt, 01_rand_19.txt, 02_maxrand_00.txt, 02_maxrand_01.txt, 02_maxrand_02.txt, 02_maxrand_03.txt, 02_maxrand_04.txt, 02_maxrand_05.txt, 02_maxrand_06.txt, 02_maxrand_07.txt, 02_maxrand_08.txt, 02_maxrand_09.txt, 02_maxrand_10.txt, 02_maxrand_11.txt, 02_maxrand_12.txt, 02_maxrand_13.txt, 02_maxrand_14.txt, 02_maxrand_15.txt, 02_maxrand_16.txt, 02_maxrand_17.txt, 02_maxrand_18.txt, 02_maxrand_19.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample1.txt |
AC |
1 ms |
256 KB |
00_sample2.txt |
AC |
1 ms |
256 KB |
00_sample3.txt |
AC |
1 ms |
256 KB |
00_sample4.txt |
AC |
1 ms |
256 KB |
01_rand_00.txt |
AC |
1 ms |
256 KB |
01_rand_01.txt |
AC |
1 ms |
256 KB |
01_rand_02.txt |
AC |
1 ms |
256 KB |
01_rand_03.txt |
AC |
1 ms |
256 KB |
01_rand_04.txt |
AC |
1 ms |
256 KB |
01_rand_05.txt |
AC |
1 ms |
256 KB |
01_rand_06.txt |
AC |
1 ms |
256 KB |
01_rand_07.txt |
AC |
1 ms |
256 KB |
01_rand_08.txt |
AC |
1 ms |
256 KB |
01_rand_09.txt |
AC |
1 ms |
256 KB |
01_rand_10.txt |
AC |
1 ms |
256 KB |
01_rand_11.txt |
AC |
1 ms |
256 KB |
01_rand_12.txt |
AC |
1 ms |
256 KB |
01_rand_13.txt |
AC |
1 ms |
256 KB |
01_rand_14.txt |
AC |
1 ms |
256 KB |
01_rand_15.txt |
AC |
1 ms |
256 KB |
01_rand_16.txt |
AC |
1 ms |
256 KB |
01_rand_17.txt |
AC |
1 ms |
256 KB |
01_rand_18.txt |
AC |
1 ms |
256 KB |
01_rand_19.txt |
AC |
1 ms |
256 KB |
02_maxrand_00.txt |
AC |
1 ms |
256 KB |
02_maxrand_01.txt |
AC |
1 ms |
256 KB |
02_maxrand_02.txt |
AC |
1 ms |
256 KB |
02_maxrand_03.txt |
AC |
1 ms |
256 KB |
02_maxrand_04.txt |
AC |
1 ms |
256 KB |
02_maxrand_05.txt |
AC |
1 ms |
256 KB |
02_maxrand_06.txt |
AC |
1 ms |
256 KB |
02_maxrand_07.txt |
AC |
1 ms |
256 KB |
02_maxrand_08.txt |
AC |
1 ms |
256 KB |
02_maxrand_09.txt |
AC |
1 ms |
256 KB |
02_maxrand_10.txt |
AC |
1 ms |
256 KB |
02_maxrand_11.txt |
AC |
1 ms |
256 KB |
02_maxrand_12.txt |
AC |
1 ms |
256 KB |
02_maxrand_13.txt |
AC |
1 ms |
256 KB |
02_maxrand_14.txt |
AC |
1 ms |
256 KB |
02_maxrand_15.txt |
AC |
1 ms |
256 KB |
02_maxrand_16.txt |
AC |
1 ms |
256 KB |
02_maxrand_17.txt |
AC |
1 ms |
256 KB |
02_maxrand_18.txt |
AC |
1 ms |
256 KB |
02_maxrand_19.txt |
AC |
1 ms |
256 KB |