QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#46003#2571. Aidana and PitaMarkkkTL 1ms5748kbC++4.0kb2022-08-24 19:56:472022-08-24 19:56:50

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-24 19:56:50]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:5748kb
  • [2022-08-24 19:56:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace Def{
#define ll long long
#define lll __int128
#define lb long double
#define D double
#define emb emplace_back
#define mkp make_pair
#define Array vector<int>
#define Pair pair<int,int>
#define fi first
#define se second
#define rep(variable,leftrange,rightrange) for(int variable=leftrange;variable<=rightrange;++variable)
#define Rep(variable,leftrange,rightrange) for(int variable=leftrange;variable>=rightrange;--variable)
#define Find(a,b) (lower_bound(a.begin(),a.end(),b)-a.begin())
#define Uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define All(x) x.begin(),x.end()
#define nxtl puts("")
#define sq(x) ((x)*(x))
#define lowbit(x) ((x)& -(x))
#define IF(x,y,z) (x)&&(y)||(z)
#define If(x,y) (x)&&(y)
}
namespace LOCAL{
#ifdef DEBUG
#define react puts("reacting now !")
#define debug(x) cout << #x << " = " <<  x << "\n"; 
#define debug2(l,r) cout << "[" #l "," #r "] = [" << l << "," << r << "]\n" ;
#define debug3(x,y,z) cout << "{" #x "," #y "," #z "} = " << "{" << x << "," << y << "," << z << "}\n" ; 
#define debug_vec(v) cout << #v": size= " << v.size() << "\nelement: " ; for(auto p:v)  cout << p << " " ;
#define FileIO(x) 
#else 
#define react
#define debug(x) 
#define debug2(l,r)
#define debug3(x,y,z)
#define debug_vec(v)
#define FileIO(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout)
#endif 
}
namespace IO {
#define MAXSIZE (1<<20)
char *IO_p1,*IO_p2,IO_buf[MAXSIZE];
#ifdef DEBUG
#define gchar() getchar()
#else
#define gchar() (IO_p1==IO_p2&&(IO_p2=(IO_p1=IO_buf)+fread(IO_buf,1,MAXSIZE,stdin),IO_p1==IO_p2)?EOF:*IO_p1++)
#endif
template<typename _Tp>inline void read(_Tp &x){
    x=0;char ch=gchar();
    for(;!isdigit(ch);ch=gchar());
    for(;isdigit(ch);ch=gchar())x=(x<<1)+(x<<3)+(ch^48);
}
template<typename _Tp>inline void nread(_Tp &x){
    x=0;_Tp f=1;char ch=gchar();
    for(;!isdigit(ch);ch=gchar())ch=='-'&&(f=-1);
    for(;isdigit(ch);ch=gchar())x=(x<<1)+(x<<3)+(ch^48);
    x*=f;
}
template<typename _Tp,typename ...Args>
inline void read(_Tp &x,Args &...args){read(x),read(args...);}
template<typename _Tp,typename ...Args>
inline void nread(_Tp &x,Args &...args){nread(x),nread(args...);}
template<typename _Tp>inline void wrt(_Tp x){
    if(x<0)x=-x,putchar('-');
    if(x>9)wrt(x/10);
    putchar(x%10+48);
}
inline void wrt(char ch){putchar(ch);}
template<typename _Tp,typename ...Args>
inline void wrt(_Tp x,Args ...args){wrt(x),wrt(args...);}
#undef MAXSIZE
}
namespace Fast{
    inline void Read(pair<int,int> &x) { IO::read(x.fi,x.se); }
    inline void Read(vector<int> &v,int n){v.resize(n);for(auto &p:v) IO::read(p);}
    inline void Wrt(pair<int,int> x,char c) { IO::wrt(x.fi,' ',x.se,c); }
    inline void Wrt(vector<int> v,char c){for(auto p:v) IO::wrt(p,c);}    
    template<typename _Tp>inline void Swap(_Tp &x,_Tp &y) {x^=y^=x^=y;}
    template<typename _Tp>inline _Tp Min(_Tp x,_Tp y){return x<y?x:y;}
    template<typename _Tp>inline _Tp Max(_Tp x,_Tp y){return x>y?x:y;}
    template<typename _Tp>inline void Add(_Tp &x,_Tp y,_Tp p){x+=y;if(x>=p)x-=p;}
    template<typename _Tp>inline void upmax(_Tp &x,_Tp y){if(y>x)x=y;} 
    template<typename _Tp>inline void upmin(_Tp &x,_Tp y){if(y<x)x=y;}
}
using namespace IO ;
using namespace Def ;
using namespace Fast ; 
using namespace LOCAL ;
const int N = 25 ;
int n , a[N] , f[1 << N] , h[1 << N] , cnt;
int t[4] , res[N] , ans = 1e9 , nw[N]; 
void c(int x) {
    if(x == n) {
        int r = *max_element(t + 1 , t + 4) - * min_element(t + 1 , t + 4) ;
        if(r < ans) {
            ans = r ;
            for(int i = 0 ; i < x ; ++ i) res[i] = nw[i] ;
        }
        return ;
    }
    for(int k = 1 ; k <= 3 ; ++ k) {
        nw[x] = k ; 
        t[k] += a[x] ;
        c(x + 1) ;
        t[k] -= a[x] ;
    }
}
void BF ( ) {
    rep(i,0,n-1) read(a[i]) ;
    c(0) ;
    rep(i,0,n-1) wrt(res[i],' ') ;
}

signed main()
{
    read(n) ;  BF( ) ;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
2 3 1 4 2

output:

1 2 2 3 1 

result:

ok answer is 0

Test #2:

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

input:

6
3 2 5 3 4 2

output:

1 2 2 1 3 3 

result:

ok answer is 1

Test #3:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

3
2617460 3290620 1468912

output:

1 2 3 

result:

ok answer is 1821708

Test #4:

score: -100
Time Limit Exceeded

input:

25
6 6 7 8 5 10 5 7 10 10 4 4 5 8 1 6 3 1 9 4 10 7 8 4 5

output:


result: