CODE FESTIVAL 2016 qual A

Submission #1753272

Source codeソースコード

#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	string s;
	cin >> s;
	int k, i, j;
	cin >> k;
	i = 0;
	while (k > 0 && i<s.size()) {
		if ('z' - s[i] + 1 <= k && s[i] != 'a') {
			k -= ('z' - s[i] + 1);
			s[i] = 'a';
		}
		i++;
	}
	while (k >= 26) {
		k -= 26;
	}
	i = s.size() - 1;
	while (k > 0) {
		if ('z' - s[i] <= k) {
			k -= ('z' - s[i]);
			s[i] = 'z';
		}
		else {
			s[i] += k;
			k = 0;
		}
		if (i > 0) {
			i--;
		}
	}
	cout << s << endl;
}

Submission

Task問題 C - 次のアルファベット / Next Letter
User nameユーザ名 fuppy
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 1232 Byte
File nameファイル名
Exec time実行時間 17 ms
Memory usageメモリ使用量 512 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_00.txt,0_01.txt,0_02.txt
All 400 / 400 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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 14 ms 256 KB
1_05.txt AC 14 ms 256 KB
1_06.txt AC 17 ms 512 KB
1_07.txt AC 17 ms 512 KB
1_08.txt AC 4 ms 512 KB
1_09.txt AC 4 ms 512 KB
1_10.txt AC 4 ms 512 KB
1_11.txt AC 4 ms 512 KB
1_12.txt AC 4 ms 512 KB
1_13.txt AC 4 ms 512 KB
1_14.txt AC 4 ms 512 KB
1_15.txt AC 5 ms 512 KB
1_16.txt AC 16 ms 512 KB
1_17.txt AC 16 ms 512 KB
1_18.txt AC 16 ms 512 KB
1_19.txt AC 16 ms 512 KB
1_20.txt AC 9 ms 512 KB
1_21.txt AC 12 ms 512 KB
1_22.txt AC 10 ms 512 KB
1_23.txt AC 15 ms 512 KB