/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 580.0 KiB
#3 Wrong Answer 2ms 580.0 KiB
#4 Wrong Answer 5ms 664.0 KiB
#5 Wrong Answer 48ms 756.0 KiB
#6 Wrong Answer 40ms 1000.0 KiB
#7 Wrong Answer 12ms 580.0 KiB
#8 Wrong Answer 20ms 580.0 KiB
#9 Wrong Answer 41ms 688.0 KiB
#10 Wrong Answer 12ms 580.0 KiB
#11 Wrong Answer 33ms 576.0 KiB
#12 Wrong Answer 321ms 972.0 KiB
#13 Wrong Answer 26ms 664.0 KiB
#14 Wrong Answer 24ms 664.0 KiB
#15 Wrong Answer 57ms 700.0 KiB
#16 Wrong Answer 97ms 732.0 KiB
#17 Wrong Answer 134ms 780.0 KiB
#18 Wrong Answer 610ms 1.383 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
const int sz= 5e3 + 5 ;


void solve()
{
   int make_A[sz] , make_B[sz] , make_C[sz] , substringCost[sz] , n , k , Ans = 0;
   string s ;
    cin >> n >> k >> s ;
    for(int i = 0 ; i < n ; i++){
        make_A[i] = (122 - s[i] + 1) % 26 ;
        make_B[i] = (122 - s[i] + 2) % 26 ;
        make_C[i] = (122 - s[i] + 3) % 26 ;
    }
    for(int i = 0 ; i <= n - 3 ; i++) {
       substringCost[i] = make_A[i] + make_B[i + 1] + make_C[i + 2] ;
    }
  vector<int> dp(k + 1, 0);
     dp[0] = 0;
    for (int i = 0; i <= n - 3  ; i++) {
        for(int j = k ; j >= substringCost[i] ; j--){
            dp[j] = max(dp[j] , dp[j - substringCost[i]] + 1) ;
        }

    }
    cout << dp[k] << "\n" ;

}
int main()
{
     __Heart__
     int t ; cin >> t ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1100 Substring ABC
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-17 10:11:57
Judged At
2024-10-03 12:56:20
Judged By
Score
2
Total Time
610ms
Peak Memory
1.383 MiB