QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#144700 | #4188. Excursion to Porvoo | value0 | WA | 55ms | 12984kb | C++20 | 1.4kb | 2023-08-21 17:54:11 | 2023-08-21 17:54:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
#define fi first
#define se second
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
int n,m;
int d[N];
int c[N];
priority_queue<piii,vector<piii>,greater<piii>> heap;
priority_queue<pii,vector<pii>,greater<pii>> q[N];
int main()
{
scanf("%d %d",&n,&m);
for(int i= 1;i<=m;i++)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
heap.push({c,{a,i}});
q[a].push({b,i});
}
int k;
int l = 0;
int r = 0;
int res = 0;
vector<pii> v;
for(int i = 1;i<n;i++)
{
res += q[i].top().fi;
}
v.push_back({heap.top().fi,res});
while(heap.size())
{
r = heap.top().fi;
while(heap.size() && heap.top().fi == r)
{
auto t = heap.top();
int i = t.se.fi;
int idx = t.se.se;
while(q[i].size() && q[i].top().se == idx)
{
res -= q[i].top().fi;
q[i].pop();
res += q[i].top().fi;
}
heap.pop();
}
if(heap.empty())
{
break;
}
auto t = heap.top();
r = t.fi;
v.push_back({r,res});
}
scanf("%d",&k);
while(k--)
{
int x;
scanf("%d",&x);
pii s = {x,0};
auto idx = lower_bound(v.begin(),v.end(),s) - v.begin();
if(idx >= v.size())
{
puts("impossible");
}
else
{
printf("%d\n",v[idx].se);
}
}
// for(auto x : v)
// {
// cout<<x.fi<<' '<<x.se<<endl;
// }
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 7016kb
input:
2 2 1 100 300 1 1 30 5 400 500 300 20 1
output:
impossible impossible 100 1 1
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 6816kb
input:
5 7 1 200 30 2 200 31 3 200 32 4 200 33 1 5000 33 2 5000 33 3 5000 33 3 30 31 33
output:
800 5600 15200
result:
ok 3 lines
Test #3:
score: 0
Accepted
time: 2ms
memory: 6768kb
input:
2 3 1 3 3 1 4 2 1 2 1 3 1 3 2
output:
2 3 3
result:
ok 3 lines
Test #4:
score: -100
Wrong Answer
time: 55ms
memory: 12984kb
input:
100000 99999 1 8793 670998 2 3301 949483 3 5662 542705 4 3033 907487 5 7035 366434 6 5771 1750 7 2575 80336 8 5163 613257 9 5748 414726 10 4990 119039 11 5855 239538 12 1965 755221 13 8891 149341 14 3213 674329 15 9189 660274 16 4593 513364 17 793 326875 18 2873 954337 19 3470 105349 20 9374 779965 ...
output:
500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 500522555 ...
result:
wrong answer 1st lines differ - expected: 'impossible', found: '500522555'