답안 #979987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979987 2024-05-11T18:51:21 Z vjudge1 봉쇄 시간 (IOI23_closing) C++17
0 / 100
49 ms 10328 KB
#include "closing.h"
#include <bits/stdc++.h>
#define ll long long
#define rep(a,b,c) for(int a=b; a<c; a++)
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back

using namespace std;

const int lim=2e5+5;
vector<pii> adj[lim];
ll ant[lim], nxt[lim];
bool vis[lim];
ll K2, a[lim];

int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W){
	if(K>3000) return 0;
	rep(i,0,N) adj[i].clear(), a[i]=0;
	rep(i,0,N-1){
		if(U[i]<V[i]) nxt[U[i]]=W[i], ant[V[i]]=W[i];
		else ant[U[i]]=W[i], nxt[V[i]]=W[i];
	}
	int ans=0;
	rep(i,0,N+1){
		rep(j,0,N+1){
			K2=K;
			int l=X, r=Y, act;
			ll sum=0, sumx=0, sumy=0, dis[N], disx[N], disy[N];
			priority_queue<ll, vector<ll>, greater<ll>> pq;
			sum=0;
			act=X;
			rep(k,0,i+1){
				dis[act]=sum;
				K-=sum;
				sum+=ant[act];
				if(sum>K || act==0) break;
				act--;
			}
			sum=0;
			act=Y;
			rep(k,0,j+1){
				dis[act]=sum;
				K-=sum;
				sum+=nxt[act];
				if(sum>K || act==N-1) break;
				act++;
			}
			sumx=0;
			sumy=0;
			while(l<r){
				if(min(sumx+nxt[l],sumy+ant[r])>K) break;
				if(sumx+nxt[l]<sumy+nxt[r]){
					sumx+=nxt[l];
					K-=sumx;
					l++;
				}else{
					sumy+=ant[r];
					K-=sumy;
					r--;
				}
			}
			rep(i,0,N){
				pq.push(max(0ll,disx[i]-dis[i]));
				pq.push(max(0ll,disy[i]-dis[i]));
			}
			while(pq.size()){
				if(K<pq.top()) break;
				ans++;
				K-=pq.top();
				pq.pop();
			}
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB 1st lines differ - on the 1st token, expected: '6', found: '896'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 49 ms 10328 KB 1st lines differ - on the 1st token, expected: '451', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB 1st lines differ - on the 1st token, expected: '3', found: '96'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB 1st lines differ - on the 1st token, expected: '3', found: '96'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB 1st lines differ - on the 1st token, expected: '3', found: '96'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB 1st lines differ - on the 1st token, expected: '6', found: '896'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB 1st lines differ - on the 1st token, expected: '6', found: '896'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB 1st lines differ - on the 1st token, expected: '6', found: '896'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB 1st lines differ - on the 1st token, expected: '6', found: '896'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB 1st lines differ - on the 1st token, expected: '6', found: '896'
2 Halted 0 ms 0 KB -