結果

問題 No.1913 Periodic Comparison
ユーザー 👑 kmjpkmjp
提出日時 2022-05-25 00:29:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,617 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 208,000 KB
実行使用メモリ 15,492 KB
最終ジャッジ日時 2023-10-20 19:02:46
合計ジャッジ時間 13,358 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
14,492 KB
testcase_01 AC 4 ms
14,488 KB
testcase_02 AC 9 ms
14,492 KB
testcase_03 AC 5 ms
14,492 KB
testcase_04 AC 4 ms
14,492 KB
testcase_05 AC 5 ms
14,492 KB
testcase_06 AC 5 ms
14,492 KB
testcase_07 AC 5 ms
14,492 KB
testcase_08 AC 17 ms
14,540 KB
testcase_09 AC 80 ms
15,368 KB
testcase_10 AC 16 ms
14,528 KB
testcase_11 AC 80 ms
15,164 KB
testcase_12 AC 52 ms
15,480 KB
testcase_13 AC 15 ms
14,512 KB
testcase_14 AC 62 ms
15,472 KB
testcase_15 AC 78 ms
15,012 KB
testcase_16 WA -
testcase_17 AC 17 ms
14,536 KB
testcase_18 AC 14 ms
14,516 KB
testcase_19 AC 79 ms
15,200 KB
testcase_20 AC 55 ms
15,020 KB
testcase_21 AC 78 ms
15,264 KB
testcase_22 AC 14 ms
14,512 KB
testcase_23 AC 12 ms
14,504 KB
testcase_24 AC 79 ms
15,136 KB
testcase_25 AC 50 ms
15,480 KB
testcase_26 AC 63 ms
15,484 KB
testcase_27 AC 15 ms
14,520 KB
testcase_28 AC 16 ms
14,532 KB
testcase_29 AC 77 ms
15,492 KB
testcase_30 AC 64 ms
15,420 KB
testcase_31 AC 12 ms
14,504 KB
testcase_32 AC 13 ms
14,508 KB
testcase_33 WA -
testcase_34 AC 80 ms
15,232 KB
testcase_35 AC 82 ms
15,244 KB
testcase_36 AC 52 ms
15,480 KB
testcase_37 AC 78 ms
15,012 KB
testcase_38 AC 5 ms
14,492 KB
testcase_39 WA -
testcase_40 AC 66 ms
15,340 KB
testcase_41 AC 71 ms
15,204 KB
testcase_42 AC 64 ms
15,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------


int N;
int X[202020],Y[202020];

int F[202020];
int R[202020];
int rev[2020202];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	MINUS(rev);
	cin>>N;
	int M=0;
	FOR(i,N) cin>>X[i];
	FOR(i,N) {
		cin>>Y[i];
		
		if(rev[Y[i]]!=-1) {
			cout<<-1<<endl;
			return;
		}
		rev[Y[i]]=i;
		
		M=max({M,X[i],Y[i]});
		
		
		
	}
	queue<int> Q;
	MINUS(R);
	FOR(i,N) Q.push(i);
	for(i=M;i>=0;i--) {
		if(Q.empty()) {
			cout<<-1<<endl;
			return;
		}
			
		x=Q.front();
		Q.pop();
		if(rev[i]>=0) {
			if(R[x]!=-1) {
				cout<<-1<<endl;
				return;
			}
			R[x]=rev[i];
			if(X[R[x]]>0) {
				Q.push(x);
			}
			F[R[x]]=i;
			X[R[x]]--;
		}
		else {
			if(R[x]!=-1) {
				if(X[R[x]]>0) {
					Q.push(x);
				}
				F[R[x]]=i;
				X[R[x]]--;
			}
			else {
				Q.push(x);
			}
		}
	}
	FOR(i,N) cout<<F[i]<<" ";
	cout<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0