QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#631222 | #8693. Money Sharing | hos_lyric | AC ✓ | 27ms | 12008kb | C++14 | 1.9kb | 2024-10-11 23:02:59 | 2024-10-11 23:02:59 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
int N, N0, N1;
vector<Int> A;
int main() {
for (; ~scanf("%d%d", &N0, &N1); ) {
N = N0 + N1;
A.resize(N);
for (int i = 0; i < N; ++i) {
scanf("%lld", &A[i]);
}
vector<int> del(N, 0);
Int now = 0;
priority_queue<pair<Int, int>, vector<pair<Int, int>>, greater<pair<Int, int>>> que;
for (int i = 0; i < N; ++i) {
now += A[i];
que.emplace(A[i], i);
for (; now < 0; ) {
now -= que.top().first;
del[que.top().second] = 1;
que.pop();
}
}
for (int i = 0; i < N; ++i) {
puts((A[i] > 0) ? "resupplied" : del[i] ? "declined" : "approved");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3964kb
input:
4 1 +5 -3 -2 -1 -1
output:
resupplied declined approved approved approved
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
10 8 -945925285 -954790330 -678603523 -300106664 +157494090 +825722895 +85146221 -697750806 +535226307 +333012397 +460250858 +126499350 -119591401 +869406887 -350140820 -225718477 -522230324 -687456340
output:
declined declined declined declined resupplied resupplied resupplied approved resupplied resupplied resupplied resupplied approved resupplied approved approved approved approved
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
9 4 -6 +8 -7 -9 -7 -5 +1 -1 -3 -7 +4 +4 -6
output:
declined resupplied declined declined declined approved resupplied approved approved declined resupplied resupplied approved
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
1 1 +1 -1
output:
resupplied approved
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
1 1 -1000000000 +1000000000
output:
declined resupplied
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
99 100 -821505971 +453018115 -472967624 +419519877 +950501906 -556578351 +756432271 -212115770 +835290474 +562962267 +557874593 -229516802 -612686312 -407351008 -454063309 +306268074 -38516508 -472151581 -728983428 +568418369 +849219194 -568047344 +980872796 -660498585 -247992282 +632806977 -2437628...
output:
declined resupplied declined resupplied resupplied approved resupplied approved resupplied resupplied resupplied approved approved approved approved resupplied approved approved approved resupplied resupplied approved resupplied approved approved resupplied approved approved resupplied resupplied re...
result:
ok ok
Test #7:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
999 992 -493266856 +429225565 +342651565 +474801816 +834022207 +448886437 -359345967 -4071423 +790212511 -440835216 +86346692 +38371595 +141401581 -870144409 -958660 +761617079 +351475924 +196803677 +776538187 +430932323 +125901568 -348046112 -689797302 +127080788 +718447010 +705850439 -68570922 +92...
output:
declined resupplied resupplied resupplied resupplied resupplied approved approved resupplied approved resupplied resupplied resupplied approved approved resupplied resupplied resupplied resupplied resupplied resupplied approved approved resupplied resupplied resupplied approved resupplied resupplied...
result:
ok ok
Test #8:
score: 0
Accepted
time: 11ms
memory: 11280kb
input:
99997 99997 -852075607 +542068229 -434497575 +795585953 +605574424 -713796366 -163788565 +540032670 -55433004 -601392886 +788730428 +704077021 +729098477 -858754135 +12844255 +501133554 +800476965 -484460895 +767723508 +337304131 +98477975 +951280207 -283006118 +904965006 -196283254 +61298173 +84039...
output:
declined resupplied approved resupplied resupplied approved approved resupplied approved approved resupplied resupplied resupplied approved resupplied resupplied resupplied approved resupplied resupplied resupplied resupplied approved resupplied approved resupplied resupplied resupplied resupplied a...
result:
ok ok
Test #9:
score: 0
Accepted
time: 22ms
memory: 11024kb
input:
100000 100000 +99860915 +655757265 -196763577 +256810460 -428608531 -128803103 -645599537 +515409627 +572729691 -58717212 -904018660 +75857674 +893787039 +787407742 -477961106 +146709208 -474765033 -508562191 -909739821 -814504201 -398218165 +903487532 +205113692 +821030196 -457624435 +823372358 -93...
output:
resupplied resupplied approved resupplied approved approved declined resupplied resupplied approved declined resupplied resupplied resupplied approved resupplied approved approved declined approved approved resupplied resupplied resupplied approved resupplied declined resupplied resupplied resupplie...
result:
ok ok
Test #10:
score: 0
Accepted
time: 26ms
memory: 11532kb
input:
100000 100000 +432453682 +525918376 -450433865 -878325807 -91489673 -829375444 -795521075 +285720922 -160980711 +996193308 +497728090 -233029332 +373952582 +612188346 -292856994 -46652368 -271821331 -491699324 +786101153 -333068886 -162165677 -861604419 -547067426 +710161346 +133042155 +547774341 +4...
output:
resupplied resupplied approved declined approved declined declined resupplied approved resupplied resupplied approved resupplied resupplied approved approved approved approved resupplied approved approved approved approved resupplied resupplied resupplied resupplied resupplied resupplied approved re...
result:
ok ok
Test #11:
score: 0
Accepted
time: 27ms
memory: 10136kb
input:
100000 100000 +766407229 +748610049 +405618969 -966567861 +582658980 +12290621 -701444024 -822892158 -93300995 +208355097 -321808360 +601021933 +22962855 +152017888 +767792826 +503581919 -718380162 +760482850 -19903267 -556733108 -20833963 +218581042 +75258489 +356465618 +106137052 -617580455 -28634...
output:
resupplied resupplied resupplied declined resupplied resupplied approved declined approved resupplied approved resupplied resupplied resupplied resupplied resupplied approved resupplied approved approved approved resupplied resupplied resupplied resupplied approved approved resupplied resupplied res...
result:
ok ok
Test #12:
score: 0
Accepted
time: 22ms
memory: 10912kb
input:
100000 100000 +233507322 +474625165 -711578025 +231029157 -919176749 +650035901 +887342107 +220344054 +555590990 +735709017 -399694330 -928600074 -776423681 +204522686 +268404101 -572043370 -321084861 +317193788 +52692236 +886660558 +462795087 +879090329 +521552246 -395184807 -859473237 +771382412 -...
output:
resupplied resupplied declined resupplied declined resupplied resupplied resupplied resupplied resupplied approved declined approved resupplied resupplied approved approved resupplied resupplied resupplied resupplied resupplied resupplied approved approved resupplied approved resupplied approved res...
result:
ok ok
Test #13:
score: 0
Accepted
time: 19ms
memory: 12008kb
input:
100000 100000 -412032042 +216360579 +321151446 -66942976 -145669171 -918327525 -658284603 -55430345 -603504341 -657410173 -381995386 +21604174 +706201371 -113667718 -293071170 +869528377 +430494583 -913386557 -598977764 -542361209 +58875963 -816631138 +785738711 -152277955 -115665441 -395251900 -135...
output:
declined resupplied resupplied approved approved declined declined approved declined declined declined resupplied resupplied approved approved resupplied resupplied declined approved approved resupplied declined resupplied approved approved approved approved resupplied resupplied approved approved r...
result:
ok ok
Test #14:
score: 0
Accepted
time: 12ms
memory: 6620kb
input:
10 100000 +836212470 +382623858 +509626495 +987584504 +941758306 +277319517 +769628 +101576795 +45466788 +20559081 +460905532 +734238124 +807964554 +278711724 +239705639 +15873355 +499158261 +604052594 +728226166 +26131468 +843346524 +503295671 +488677723 +841367224 +633182278 +367694640 +597968217 ...
output:
resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied res...
result:
ok ok
Test #15:
score: 0
Accepted
time: 12ms
memory: 4472kb
input:
100000 10 -837386654 -340185040 -98936604 -677313698 -527661705 -481963618 -218403179 -812487102 -234751675 -903415337 -594676444 -150293742 -710481096 -492027784 -377561228 -727469359 -70913782 -69385142 -202139787 -726451604 -390813118 -643883839 -505170015 -923042240 -660682833 -383072387 -352492...
output:
declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined dec...
result:
ok ok
Test #16:
score: 0
Accepted
time: 8ms
memory: 6620kb
input:
20 100000 +472410768 +207395914 +815120674 +224296234 +942743645 +19175081 +683931901 +710735385 +151759656 +17879414 +897195967 +973370078 +885625078 +147493185 +517397030 +848809556 +863891681 +227765706 +332015943 +350399942 +98419095 +278782602 +936608008 +699708788 +382082009 +941309739 +476224...
output:
resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied res...
result:
ok ok
Test #17:
score: 0
Accepted
time: 12ms
memory: 4672kb
input:
100000 20 -658486304 -587580787 -925194602 -63951644 -185962141 -625869718 -270298779 -845732620 -349686724 -713092845 -990920604 -963331127 -669154475 -166606328 -183846564 -199206417 -674788041 -876412989 -952947853 -481557329 -441468538 -720522948 -843331925 -117278322 -933654399 -337073820 -1009...
output:
declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined dec...
result:
ok ok
Test #18:
score: 0
Accepted
time: 12ms
memory: 6512kb
input:
100 100000 +317933796 +701213270 +109130228 +630134971 +262104873 +779934272 +295794632 +833173390 +440492907 +908217439 +164370180 +618710559 +147728929 +499569360 +26354289 +251644461 +937706374 +761580306 +728849628 +648917274 +890411033 +27111049 +288820630 +717361772 +594834717 +163051775 +5824...
output:
resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied res...
result:
ok ok
Test #19:
score: 0
Accepted
time: 13ms
memory: 4776kb
input:
100000 100 -700978892 -747149391 -14055401 -983666971 -729665021 -483561231 -508994439 -889137533 -445756019 -551793155 -965752242 -299123269 -449764870 -649682651 -131237405 -720996237 -179275745 -491553981 -836609806 -132176420 -267316484 -282084544 -175622110 -124177933 -452235970 -685082226 -104...
output:
declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined dec...
result:
ok ok
Test #20:
score: 0
Accepted
time: 7ms
memory: 6524kb
input:
10000 100000 +430294302 +757983469 -13345109 +867950320 +351869766 +971543215 +137983012 +623941447 +875845157 +222431101 +234538392 +85506801 +698126651 +298914962 +786718670 +157793364 +461869795 -225506336 +650522360 +518734860 +325648071 +444063180 +760275931 +759882087 +844069990 +222945581 +81...
output:
resupplied resupplied approved resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied approved resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resuppl...
result:
ok ok
Test #21:
score: 0
Accepted
time: 16ms
memory: 5704kb
input:
100000 10000 -564580226 -375543448 -659098416 -712159843 -66197953 -692791971 -850263486 -304616895 -427011818 -526697753 -227913362 -975110019 -501984553 -162481905 -113691411 -65737072 -386843841 -804975447 -687497725 -305952443 -436149382 -27921447 -743083487 -293501068 -637931107 -649730678 +689...
output:
declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined declined resupplied declined declined declined approved declined approved r...
result:
ok ok
Test #22:
score: 0
Accepted
time: 11ms
memory: 10924kb
input:
99724 99053 +1 +1 +1 -1 +1 -1 +1 +1 +1 +1 +1 +1 -1 +1 +1 +1 +1 +1 +1 +1 +1 -1 +1 +1 -1 -1 -1 +1 -1 +1 +1 +1 +1 +1 -1 -1 -1 +1 +1 +1 -1 -1 +1 -1 +1 +1 -1 -1 +1 +1 +1 -1 -1 +1 +1 -1 -1 +1 -1 -1 +1 +1 +1 +1 +1 +1 +1 -1 -1 +1 +1 +1 +1 -1 +1 +1 -1 -1 -1 +1 +1 +1 +1 -1 +1 -1 -1 +1 +1 -1 +1 +1 +1 +1 +1 -1 ...
output:
resupplied resupplied resupplied declined resupplied declined resupplied resupplied resupplied resupplied resupplied resupplied declined resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied declined resupplied resupplied declined declined declined resupplied declin...
result:
ok ok
Test #23:
score: 0
Accepted
time: 20ms
memory: 11004kb
input:
99137 99214 +1 +1 +2 +2 +1 +1 +2 +1 +1 -1 -1 -1 -2 +2 +2 -2 -1 -1 +2 -1 -2 +1 -1 +1 -1 -1 -2 +1 -1 +2 -1 -1 +1 +1 +2 -1 +2 -2 +2 +1 +2 +1 -2 -1 +2 +1 -2 -1 -1 +1 +2 +2 -2 -1 -1 +2 +2 -2 +1 -2 -1 +1 -1 -1 -2 -1 -2 -1 -2 +1 -1 -2 -2 +2 -1 +1 +2 +1 +2 -1 +2 +2 -1 -2 +2 +1 -1 +1 +1 +2 +1 -1 +2 +2 +2 +2 ...
output:
resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied approved approved approved declined resupplied resupplied declined approved approved resupplied approved declined resupplied approved resupplied approved approved declined resupplied approved resupplie...
result:
ok ok
Test #24:
score: 0
Accepted
time: 8ms
memory: 10236kb
input:
99590 99726 +7 -1 +8 -7 +9 +10 -7 -7 +4 +1 +10 -6 +1 -9 -9 -4 -4 +7 +9 +1 -5 +1 -7 -5 +1 -2 +4 -3 +3 +8 -2 -9 +3 +8 -8 -3 -6 -1 +3 +9 -8 -5 -10 -2 +4 -4 +8 -1 +4 -4 +10 -2 +10 +8 -6 +7 -5 -4 -9 -8 -10 -6 +9 -5 -5 -8 -6 +9 -10 +10 +3 +8 +7 +9 -8 -3 -1 -2 -3 +9 +6 -3 -4 +2 +9 +10 -3 -8 -5 +6 -5 +7 +8 ...
output:
resupplied approved resupplied approved resupplied resupplied approved approved resupplied resupplied resupplied approved resupplied declined declined approved approved resupplied resupplied resupplied approved resupplied approved approved resupplied approved resupplied approved resupplied resupplie...
result:
ok ok
Test #25:
score: 0
Accepted
time: 18ms
memory: 11280kb
input:
99329 99489 -17 -3 +6 -17 +1 -6 +5 +5 -7 +5 -16 -1 +1 +18 +12 +5 +19 +10 +15 -1 +18 +3 +5 +12 -10 +15 -5 +10 +4 -19 -11 +14 +5 -17 -5 -5 +4 -6 -15 -17 +8 -4 -5 +11 -16 -17 -13 -10 -9 +15 +6 -1 +15 +18 -2 -5 -16 +17 -1 +16 +20 -13 +20 +11 -16 +8 -7 +10 -11 -4 -4 -11 +8 +1 +9 +10 +9 -18 -14 -19 -1 +1 ...
output:
declined declined resupplied declined resupplied approved resupplied resupplied approved resupplied declined approved resupplied resupplied resupplied resupplied resupplied resupplied resupplied approved resupplied resupplied resupplied resupplied approved resupplied approved resupplied resupplied a...
result:
ok ok
Test #26:
score: 0
Accepted
time: 17ms
memory: 11808kb
input:
99748 99238 +56 -50 -61 +80 -95 -30 +30 -96 -98 -73 -41 +87 -26 +52 +19 +30 +95 -17 +33 +86 +100 +75 +36 +81 -44 -24 +34 +37 +63 +84 -98 -48 +24 -61 +76 +17 +29 +22 +75 -29 -1 +42 +5 -8 +61 +35 +11 +94 +7 +69 -54 +86 -61 -55 +59 +10 +60 +30 -28 +4 +67 -29 -13 +31 -52 +62 -39 -24 +42 +39 -89 +86 -29 ...
output:
resupplied approved declined resupplied declined approved resupplied declined declined declined approved resupplied approved resupplied resupplied resupplied resupplied approved resupplied resupplied resupplied resupplied resupplied resupplied approved approved resupplied resupplied resupplied resup...
result:
ok ok
Test #27:
score: 0
Accepted
time: 11ms
memory: 10224kb
input:
99081 99403 -118 -636 -418 +531 -530 -986 -978 +343 +470 +296 +13 +518 -242 -827 +221 +31 -238 +263 -522 -24 -345 +360 -80 -839 +283 -813 -662 -28 -284 -72 -887 -700 +210 +847 +29 +800 -911 +734 +841 -572 -897 -299 -116 -968 -633 +337 -66 +434 -540 -886 -994 -738 -925 +244 +231 +477 -33 -211 +474 +8...
output:
declined declined declined resupplied approved declined declined resupplied resupplied resupplied resupplied resupplied approved declined resupplied resupplied approved resupplied approved approved approved resupplied approved declined resupplied declined approved approved approved approved declined...
result:
ok ok
Test #28:
score: 0
Accepted
time: 23ms
memory: 10492kb
input:
99907 99227 +60677 -87719 -29843 -34157 -15411 -45369 +62496 -17732 +58614 +98395 -16360 -45589 +8375 -25607 -42752 +4406 +56182 +9805 -54449 +33905 +9285 +178 -3318 -12131 -88523 -60428 +72929 -64285 +47714 +25159 -11702 +10759 -23896 +77986 -6317 -91800 +6642 +57363 +7348 +78047 +54885 -53119 -240...
output:
resupplied declined approved declined approved declined resupplied approved resupplied resupplied approved approved resupplied approved approved resupplied resupplied resupplied approved resupplied resupplied resupplied approved approved declined approved resupplied approved resupplied resupplied ap...
result:
ok ok
Test #29:
score: 0
Accepted
time: 21ms
memory: 10648kb
input:
99304 99568 -44888259 -444223524 +985116168 +800633287 +296091553 +395442368 +399616168 +842710971 -35769847 +87226405 +521300735 -288569125 +576869337 -186721741 -744843418 -661807756 +485259242 +520399335 -364719319 +171653224 +650378726 -725895638 +705430891 -575378341 +77949722 -223201456 -77649...
output:
declined declined resupplied resupplied resupplied resupplied resupplied resupplied approved resupplied resupplied approved resupplied approved approved approved resupplied resupplied approved resupplied resupplied approved resupplied approved resupplied approved approved resupplied resupplied appro...
result:
ok ok
Test #30:
score: 0
Accepted
time: 17ms
memory: 5684kb
input:
91801 17801 +390584741 +99768283 +875443796 +969172507 +570470526 +509931532 +606876248 +168787234 +883844260 +331207693 +75106410 +372168598 +301068264 +697409711 +876584134 +3345860 +613579662 +761494871 +939170394 +367348171 +675479246 +284636287 +748358472 +150245918 +602342230 +235054644 +79773...
output:
resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied res...
result:
ok ok
Test #31:
score: 0
Accepted
time: 14ms
memory: 6640kb
input:
90742 21425 +179363498 +714130462 +145484339 +865015905 +475830032 +975697190 +817360408 +495002069 +330955024 +71027111 +408485440 +825585494 +192219971 +817226260 +341670175 +891743677 +133625237 +648767055 +66646457 +636589209 +225071044 +911486514 +761136680 +779635372 +836804580 +751666186 +747...
output:
resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied res...
result:
ok ok
Test #32:
score: 0
Accepted
time: 13ms
memory: 7088kb
input:
100000 50000 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 ...
output:
resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied resupplied res...
result:
ok ok