QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#43634#4238. Zero SumjustcylTL 12ms8108kbC++201.6kb2022-08-09 20:41:582022-08-09 20:41:59

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-09 20:41:59]
  • 评测
  • 测评结果:TL
  • 用时:12ms
  • 内存:8108kb
  • [2022-08-09 20:41:58]
  • 提交

answer

#include <bits/stdc++.h>
#define F(i, x, y) for (int i = x; i <= y; i++)
#define D(i, x, y) for (int i = x; i >= y; i--)
#define pr printf
#define mst(a,b) memset(a,b,sizeof a)
#define SZ(x) ((int)x.size())
#define ll long long
#define x first
#define y second
#define pb emplace_back
#define mp make_pair
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr) 
#define YN(ok) cout << (ok ? "YES" : "NO") << '\n';

#ifdef LOCAL_DEFINE
#include "bits/debug.h"
#else
    #define DEB(...)  
#endif

using namespace std;

void read(){}
template<typename T,typename... T2>inline void read(T &x,T2 &... oth) { x=0;int ch=getchar(),f=0;while(ch<'0'||ch>'9') { if (ch=='-') f=1;ch=getchar();}while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}if(f)x=-x;read(oth...);}

const int N = 35001,M=114514;
const ll inf=1152921504606846976;
ll f[M*2+1],g[M*2+1];
vector<ll> a[N];
int n,m,C;

signed main()
{
#ifdef LOCAL_DEFINE
   freopen("temp.in", "r", stdin);
#endif
    srand(time(0));

    read(n,m);
    F(i,1,n){
        a[i].resize(m+m+2);
        F(j,0,m+m) read(a[i][j]);
    }
    C=M;
    DEB(C);
    // sort(a+1,a+n+1,cmp);
    random_shuffle(a+1,a+n+1);
    F(i,1,n){
        // DEB(a[i]);
    }
    F(i,0,C*2) f[i]=inf;
    f[C]=0;
    
    F(i,1,n){
        F(i,0,C*2) g[i]=inf;
        // DEB(SZ(g));
        F(j,0,m+m){
            F(k,m-j,C*2){
                if(j+k>C*2) break;
                g[j-m+k]=min(g[j-m+k],f[k]+a[i][j]);
                // DEB(g[C]);
            }
        }
        swap(f,g);
    }
    pr("%lld",f[C]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 1
3 14 15
-3 -5 -35
2 71 82

output:

-19

result:

ok 1 number(s): "-19"

Test #2:

score: 0
Accepted
time: 3ms
memory: 8036kb

input:

5 2
1 2 5 14 42
1 2 3 5 8
1 2 4 8 16
1 2 3 4 5
1 2 6 24 120

output:

16

result:

ok 1 number(s): "16"

Test #3:

score: 0
Accepted
time: 11ms
memory: 8008kb

input:

10 2
-904071845 760493887 -478285804 759035367 -680013382
-587322944 665345507 -20509293 103731947 864888628
738633646 936703855 -370523881 301151360 478433861
703775172 -913389861 691762973 -185132991 543994805
-511007159 118916858 891184 349354959 267412081
-663269925 14450557 369277951 237764429 ...

output:

-6259997315

result:

ok 1 number(s): "-6259997315"

Test #4:

score: 0
Accepted
time: 12ms
memory: 8108kb

input:

10 2
-566639283 -281454349 687175663 817449090 928108928
-819788458 -442586076 -451652406 403601435 -168825683
-649266596 187412594 -856159947 476347172 20574258
-390470703 -791341926 -60895976 842388030 507828204
159048971 -531035734 -110061386 255061473 -622553675
767534638 296274618 318355641 -60...

output:

-5863402983

result:

ok 1 number(s): "-5863402983"

Test #5:

score: -100
Time Limit Exceeded

input:

35000 2
-323024395 123746159 618869974 -455533063 294962647
9971372 784839881 -906564905 -578266269 944975915
968956358 -576765224 448197684 986539127 -525297570
-745293354 426913995 129954892 255813154 -243728523
-922616050 -983803120 -317189892 362753890 481320837
-626411581 760532893 481031139 14...

output:


result: