QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#606880#5561. Improving ITwhale_island#WA 0ms3816kbC++202.6kb2024-10-03 12:49:582024-10-03 12:49:59

Judging History

你现在查看的是最新测评结果

  • [2024-10-03 12:49:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3816kb
  • [2024-10-03 12:49:58]
  • 提交

answer

//   __________________
//  | ________________ |
//  ||          ____  ||
//  ||   /\    |      ||
//  ||  /__\   |      ||
//  || /    \  |____  ||
//  ||________________||
//  |__________________|
//  \###################\
//   \###################\
//    \        ____       \
//     \_______\___\_______\
// An AC a day keeps the doctor away.
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define hutao_my_wife ios_base::sync_with_stdio(0);
#define forcalors_so_cute cin.tie(0);
/*

struct A {
	public: [[nodiscard]] virtual const unsigned long long reference operator bitor (const unsigned long long reference a) const noexcept;

};

struct B: public A{

	public: [[nodiscard]] virtual const unsigned long long reference operator bitor (const unsigned long long reference a) const noexcept override final {

	
	}

};

inline char readchar() noexcept {
    static char buffer[BUFSIZ], * now = buffer + BUFSIZ, * end = buffer + BUFSIZ;
    if (now == end)
    {
        if (end < buffer + BUFSIZ)
            return EOF;
        end = (buffer + fread(buffer, 1, BUFSIZ, stdin));
        now = buffer;
    }
    return *now++;
}
inline int nextint() noexcept {
    int x = 0, c = readchar(), neg = 0;
    while(('0' > c || c > '9') && c!='-' && c!=EOF) c = readchar();
    if(c == '-') neg = true, c = readchar();
    while('0' <= c && c <= '9') x = (x<<3) + (x<<1) + (c^'0'), c = readchar();
    if(neg) x = -x;
    return x; // returns 0 if EOF
}

//fast io cin>>a 改成 a = nextint();
*/
#define ll long long
//#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define ALL(v) v.begin(), v.end()
#define bug(A) cout<<A<<" hi\n";
using namespace std;

const ll M = 500005;
ll n,m;

void solve(){
    cin>>n>>m;
    vector<vector<ll>>val(n+1,vector<ll>(m+1,0)),dp(n+1,vector<ll>(m+1,0));
    vector<ll>mn(m,1e15);
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= min(m,n-i+1); j++){
            cin>>val[i][j];
        }
    }
    mn[0] = 0;
    int pos = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= min(m,n-i+1); j++){
            dp[i][j] = mn[pos] + val[i][0] - val[i][j];
            mn[(pos + j)%m] = min(mn[(pos + j)%m],dp[i][j]);
        }
        pos++;
        pos%=m;
    }
    ll ans = 1e15;
    cout<<mn[pos]<<'\n';


}

signed main(){
//
    hutao_my_wife    forcalors_so_cute

    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

4 3
1000 900 800 900
700 600 500 400
1200 1200 1300
600 500

output:

100

result:

ok single line: '100'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

3 2
200 300 400
400 300 200
300 500

output:

-400

result:

ok single line: '-400'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

1 1
145669255 454927004

output:

-309257749

result:

ok single line: '-309257749'

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3816kb

input:

1 1
639426798 25010755

output:

0

result:

wrong answer 1st lines differ - expected: '614416043', found: '0'