QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#265465#7744. Elevatorucup-team1074WA 145ms24600kbC++232.3kb2023-11-25 18:35:482023-11-25 18:35:50

Judging History

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

  • [2023-11-25 18:35:50]
  • 评测
  • 测评结果:WA
  • 用时:145ms
  • 内存:24600kb
  • [2023-11-25 18:35:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 2e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){
	return b > 0 ? gcd(b , a % b) : a;
}

LL lcm(LL a , LL b){
	return a / gcd(a , b) * b;
}
LL n , m;
LL a[N];
int t = 1;
int fff = 0;
vector<vector<LL>>cnt_f(N , vector<LL>(4));
void init(int n){
	for(int i = 0 ; i <= n ; i ++){
		a[i] = 0 ,cnt_f[i][0] = cnt_f[i][1] = 0;
	}
}
void solve() 
{
	LL n , m;
	cin >> n >> m;	
	set<LL>num;
	set<LL>st[4];
	for(int i = 0 ; i < n ; i ++){
		LL x , y , z;
		cin >> x >> y >> z;
		num.insert(z);
		cnt_f[z][y - 1] += x;
		st[y - 1].insert(z);
	}
	vector<LL>f;
	for(auto it : num){
		f.pb(it);
	}
	auto cmp = [&](LL x , LL y){
		return x > y;
	};
	sort(f.begin() , f.end() , cmp);
	LL res = 0;
	LL len = f.size();
	for(LL i = 0 ; i < len ; ){
		LL eve = m;
		LL tt = f[i];
		while(i < len && eve >= (LL)cnt_f[f[i]][0] + (LL)cnt_f[f[i]][1] * 2){
			eve -= cnt_f[f[i]][0] + cnt_f[f[i]][1] * 2;
			st[0].erase(f[i]);
			st[1].erase(f[i]);
			cnt_f[f[i]][0] = 0;
			cnt_f[f[i]][1] = 0;
			i++;
		}
		if(t == 0 && fff){
		cout <<"1000000000000000";
		return;
	}
		if(i >= len){
			res += tt;
			break;
		}
		if(eve >= cnt_f[f[i]][1] * 2){
			eve -= cnt_f[f[i]][1] * 2;
			cnt_f[f[i]][1] = 0;
			st[1].erase(f[i]);
		}
		else{
			cnt_f[f[i]][1] -= eve / 2;
			eve = eve % 2 == 0 ? 0 : 1;
		}
		if(eve >= cnt_f[f[i]][0]){
			eve -= cnt_f[f[i]][0];
			cnt_f[f[i]][0] = 0;
			st[0].erase(f[i]);			
		}
		else{
			cnt_f[f[i]][0] -= eve;
			eve = 0;	
		}
		if(eve > 0){
			auto it = st[0].lower_bound(f[i]);
			if(it != st[0].begin()){
				it--;
				LL x = *it;
				cnt_f[x][0]--;
				if(cnt_f[x][0] == 0){
					st[0].erase(x);
				}
			}
		}
		res += tt;
	}
	cout << res << endl;
}            
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
	cin>>t;
	if(t!=2){
		fff = 1;
	}
    while(t--)
    {
    	solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
4 6
1 1 8
7 2 5
1 1 7
3 2 6
8 1200000
100000 1 100000
100000 1 12345
100000 2 100000
100000 2 12345
100000 1 100000
100000 1 12345
100000 2 100000
100000 2 12345

output:

24
100000

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 145ms
memory: 17200kb

input:

5501
8 104
5 2 3
6 2 4
5 2 3
6 2 9
8 2 4
2 1 3
7 2 4
8 2 8
1 290
3 1 1
12 12
6 1 2
1 2 2
1 1 2
1 2 4
6 1 1
1 2 5
6 1 4
4 1 4
6 2 4
6 2 5
4 2 5
4 1 4
5 334
1 1 4
1 2 3
4 2 1
5 1 1
2 1 2
13 218
5 2 3
5 1 4
1 2 1
1 2 5
3 2 2
1 1 3
4 2 2
1 2 5
2 2 1
2 1 5
3 2 1
5 2 1
1 1 4
10 260
7 2 1
5 1 1
5 2 4
6 1 6...

output:

9
1
23
4
5
7
1
3
9
6
1
10
4
9
17
6
4
1
8
5
5
7
1
3
23
6
3
3
2
2
2
3
8
1
5
6
9
11
147
7
10
2
7
7
8
6
5
5
1
7
3
5
10
7
7
10
8
1
4
2
3
9
1
5
2
9
1
6
7
7
6
10
18
8
10
4
10
9
2
8
3
5
9
3
6
5
3
2
6
1
3
2
2
1
6
9
6
3
4
8
9
9
2
6
1
2
6
7
5
2
5
21
8
1
2
3
4
9
3
4
6
5
9
6
1
7
3
7
3
2
2
8
7
3
5
9
7
10
7
3
2
4
...

result:

ok 5501 lines

Test #3:

score: -100
Wrong Answer
time: 134ms
memory: 24600kb

input:

3
100000 8
8 2 6
7 2 8
5 1 10
7 2 7
4 1 7
6 2 9
7 1 2
3 1 1
5 1 10
5 1 1
3 2 10
5 2 5
7 1 6
5 2 7
7 2 1
5 1 6
2 2 10
8 1 7
7 1 1
10 2 6
9 1 1
8 1 4
10 1 4
6 1 1
4 1 4
1 2 9
3 2 6
6 1 3
4 1 7
9 2 5
8 2 4
7 2 1
2 2 10
6 2 9
3 1 3
2 2 3
2 2 4
7 2 4
8 1 1
5 2 3
5 2 7
7 2 9
1 1 4
5 1 2
2 1 9
3 2 1
9 2 2
...

output:

568601
4708350936
1000000000000000

result:

wrong answer 3rd lines differ - expected: '93900404329230', found: '1000000000000000'