QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676512 | #7622. Yet Another Coffee | xcyyyyy | WA | 1ms | 5924kb | C++20 | 947b | 2024-10-25 21:54:25 | 2024-10-25 21:54:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define fr first
#define se second
#define ls u<<1
#define rs u<<1|1
#define M 10000005
#define p 998244353
#define pb push_back
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
struct node{ll val,cut;};
int n,m;
node a[N];
ll prmx[N],sfmn[N];
void sol(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%lld",&a[i].val),a[i].cut=0;
for(int i=1,x,y;i<=m;i++)scanf("%d%d",&x,&y),a[x].cut+=y;
for(int i=n;i;i--)a[i].cut+=a[i+1].cut;
sort(a+1,a+1+n,[](const node &x,const node &y){return x.val<y.val;});
for(int i=1;i<=n;i++)prmx[i]=max(prmx[i-1],a[i].cut);
sfmn[n+1]=inf;for(int i=n;i;i--)sfmn[i]=min(sfmn[i+1],a[i].val-a[i].cut);
ll prsum=0;
for(int k=1;k<=n;k++){
printf("%lld ",min(prsum+sfmn[k],prsum+a[k].val-prmx[k]));
prsum+=a[k].val;
}puts("");
}
int main(){
int t;scanf("%d",&t);while(t--)
sol();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5924kb
input:
5 10 14 17 37 59 65 53 73 68 177 160 111 10 177 5 193 2 30 3 63 2 339 3 263 5 178 2 190 9 23 10 328 10 200 9 8 3 391 6 230 12 9 152 306 86 88 324 59 18 14 42 260 304 55 3 50 2 170 1 252 7 811 1 713 7 215 10 201 4 926 8 319 19 20 182 74 180 201 326 243 195 31 170 263 284 233 48 166 272 281 179 116 31...
output:
-2596 -2559 -2506 -2447 -2382 -2314 -2241 -2130 -1970 -1793 -3505 -3491 -3473 -3431 -3376 -3317 -3231 -3143 -2883 -2579 -2273 -1949 -6527 -6496 -6448 -6374 -6258 -6092 -5922 -5743 -5563 -5368 -5167 -4934 -4691 -4428 -4156 -3875 -3591 -3272 -2946 -9203 -8971 -8556 -8124 -7691 -7222 -6752 -6258 -57...
result:
wrong answer 42nd numbers differ - expected: '-3219', found: '-9203'