QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695508#9528. New Energy VehicleJiangnan01WA 274ms29364kbC++202.2kb2024-10-31 20:11:192024-10-31 20:11:20

Judging History

This is the latest submission verdict.

  • [2024-10-31 20:11:20]
  • Judged
  • Verdict: WA
  • Time: 274ms
  • Memory: 29364kb
  • [2024-10-31 20:11:19]
  • Submitted

answer

#include <bits/stdc++.h>
#include<iostream>
using namespace std;
#define fs first
#define endl '\n'
#define sc second
#define pb push_back
#define int long long
#define itn int 
#define ull unsigned long long
#define bit(x) (1ll << (x))
#define sz(x) (int)(x).size()
#define al(x) (x).begin(),(x).end()
#define all(x) (x).begin() + 1,(x).end()
using ll = long long;
using VI = vector <int>;
using VS = vector <string>;
using PII = pair <int, int>;
using I64 = unsigned long long;
using VVI = vector < vector<int> >;
const int INF = bit(60);
const int inf=1e9+10;
const int maxn=1e6+5;
const int mod=998244353;
const double pi = acos(-1.0);
const double eps=1e-12;
void solve()
{
	int n,m;cin>>n>>m;
	VI a(n+1),tmp(n+1);
    vector<int> f(n+1);
    map<int,set<int>> mp1;
	for(int i=1;i<=n;i++) cin>>a[i],tmp[i]=a[i];
	vector<PII> v(m+1);
	map<int,int> mp;
	for(int i=1;i<=m;i++){
		cin>>v[i].fs>>v[i].sc;
		mp[v[i].sc]=1;
        mp1[v[i].second].insert(v[i].first);
	}
	sort(all(v));
	priority_queue<PII,vector<PII>,greater<PII> >q;
    set<pair<int,int>> st;
	for(int i=1;i<=m;i++)
		q.push(v[i]),st.insert(v[i]);
	for(int i=1;i<=n;i++){
		if(mp.count(i)) continue;
		q.push({INF,i});
        st.insert({INF,i});
	}
	int pos=0;
	for(int i=0;i<m;i++)
	{
		int d=v[i+1].fs-v[i].fs;
		pos+=d;
		while(!q.empty()){
			auto u=q.top();q.pop();
            st.erase(u);
            f[u.second]=u.first;
			if(d<=tmp[u.sc]){
				tmp[u.sc]-=d;d=0;
				break;
			}
			d-=tmp[u.sc];tmp[u.sc]=0;
		}
        auto it = mp1[v[i+1].second].lower_bound(v[i+1].first);
        it++;
        while(it!=mp1[v[i+1].second].end() && (*it)<=f[v[i+1].second])
        {
            q.push({*it,v[i+1].second});
            st.insert({*it,v[i+1].second});
            it++;
        }
		if(d>0){
			cout<<pos-d<<endl;return ;
		}
		tmp[v[i+1].sc]=a[v[i+1].sc];
		q.push({INF,v[i+1].sc});
		st.insert({INF,v[i+1].second});
	}
	int res=0;
	for(int i=1;i<=n;i++) res+=tmp[i];
	cout<<pos+res<<endl;
}
signed main(){ 
   	ios::sync_with_stdio(false);
   	cin.tie(nullptr);
   	cout.tie(nullptr);
	int T = 1;   
    cout << fixed << setprecision(15);
    cin >> T;
    while(T--){
    	solve();
	}
    return 0;
}

詳細信息

Test #1:

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

input:

2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1

output:

12
9

result:

ok 2 lines

Test #2:

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

input:

6
3 2
2 2 2
6 1
7 1
2 2
3 3
2 1
6 2
2 3
2 2
5 1
7 2
9 1
2 2
3 3
2 1
6 2
1 1
999999999
1000000000 1
1 1
1000000000
1000000000 1

output:

9
11
4
11
999999999
2000000000

result:

ok 6 lines

Test #3:

score: -100
Wrong Answer
time: 274ms
memory: 29364kb

input:

10
230 8042
599 1039 69 1011 1366 824 14117 1523 806 5002 332 55 3769 996 359 1040 255 1135 3454 3609 6358 2509 3695 8785 3890 1304 3394 14611 33 89 2245 508 22 1043 10411 628 1279 714 903 585 7413 5099 845 148 4689 2110 8683 1613 143 3263 2599 110 244 3297 4742 1571 425 1822 15692 572 9397 328 1691...

output:

1541626
1578773
1418041
1527007
1545236
1564121
539764
1547840
663630
591753

result:

wrong answer 1st lines differ - expected: '1543020', found: '1541626'