Submission #7095418


Source Code Expand

/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int cost_to_a(char c) {
  return (int) ('z' - c + 1);
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  int k; cin >> k;

  for (int i = 0, n = s.size(); i < n; ++i) {
    if (k <= 0) break;
    if (k >= cost_to_a(s[i])) {
      k -= cost_to_a(s[i]);
      s[i] = 'a';
    }
  }

  k %= 26;
  s.back() += k;

  cout << s << '\n';

  return 0;
}

Submission Info

Submission Time
Task C - Next Letter
User kyomukyomupurin
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2012 Byte
Status WA
Exec Time 2 ms
Memory 592 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 19
WA × 8
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 1 ms 256 KB
1_03.txt AC 1 ms 256 KB
1_04.txt AC 1 ms 256 KB
1_05.txt AC 1 ms 256 KB
1_06.txt AC 2 ms 592 KB
1_07.txt AC 2 ms 592 KB
1_08.txt WA 1 ms 512 KB
1_09.txt WA 1 ms 512 KB
1_10.txt WA 2 ms 592 KB
1_11.txt WA 2 ms 512 KB
1_12.txt WA 1 ms 512 KB
1_13.txt WA 1 ms 512 KB
1_14.txt WA 2 ms 512 KB
1_15.txt WA 2 ms 512 KB
1_16.txt AC 2 ms 512 KB
1_17.txt AC 2 ms 512 KB
1_18.txt AC 2 ms 512 KB
1_19.txt AC 2 ms 592 KB
1_20.txt AC 2 ms 512 KB
1_21.txt AC 2 ms 592 KB
1_22.txt AC 2 ms 512 KB
1_23.txt AC 2 ms 512 KB