QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#249313 | #7622. Yet Another Coffee | ucup-team992# | WA | 1ms | 3528kb | C++17 | 1.7kb | 2023-11-12 03:02:06 | 2023-11-12 03:02:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef int uci;
#define int long long
#define F first
#define S second
#define ar array
void solve(){
int N,M,K; cin >> N >> M;
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>> > SA;
vector<int> A(N); vector<pair<int,int>> RW(M);
for(int i = 0; i < N; i++) {
cin >> A[i];
SA.push({A[i], i});
}
for(int i = 0; i < M; i++) {
cin >> RW[i].F >> RW[i].S;
RW[i].F--;
}
sort(RW.begin(), RW.end());
multiset<int> be;
vector<int> added(M);
int mip = A[0];
int earn = 0;
int j = 0;
for(int i = 0; i < N; i++) {
mip = min(mip, A[i]);
while(j < M && i >= RW[j].F) {earn += RW[j++].S; added[j-1] = earn - mip; be.insert(earn-mip);};
}
int jj = M-1;
int earnd = 0;
int mi = M;
int tc = 0;
for(int i = 0; i < N; i++) {
int la = SA.top().first;
mi = min(mi, SA.top().second);
SA.pop();
//for(auto x: be) cout << x << endl;
while(jj >= 0 && mi <= RW[jj].F) { be.erase(be.find(added[jj])); earnd += RW[jj--].S; }
//cout << "(" << la << " " << tc << " " << earnd<< " " << be.size() << ")" << endl;
int score = la + tc - earnd;
if(be.size()) score = min(score, tc - *be.rbegin());
tc += la;
cout << score;
if(i == N-1) cout << '\n'; else cout << ' ';
}
//cout << "ok" << endl;
}
uci main(){
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t; cin >> t;
for(int i = 0; i < t; i++)
solve();
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3528kb
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 -3119 -2011 -1993 -1951 -1896 -2248 -2160 -3143 -2883 -2579 -2273 -1949 -4500 -4452 -6267 -6151 -5985 -5815 -5636 -5456 -5563 -5368 -5167 -4934 -4691 -4428 -4156 -3875 -3591 -3272 -2946 -3235 -1560 -2572 -2140 -1707 -1238 -768 -274 243 1046...
result:
wrong answer 11th numbers differ - expected: '-3505', found: '-3119'