# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
395323 | iulia13 | Coins (BOI06_coins) | C++14 | 302 ms | 324 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
#define ll long long
struct ura{
int x, y;
};
ura v[500005];
ura ans;
int main()
{
ll n, k, s = 0, cnt = 0, nr = 0;
cin >> n >> k;
for(int i = 1; i <= n; i++)
{
ll c, tip;
cin >> c >> tip;
if (c > s && tip == 0) ///rest
{
if (ans.x < nr || (ans.x == nr && ans.y > s))
{
ans.x = nr;
ans.y = s;
}
while (cnt && v[cnt].y) ///useless
{
s -= v[cnt].x;
cnt--;
}
s += c;
nr++;
cnt++;
v[cnt] = {c, tip};
}
else
if (c <= s)
{
/*a1 + ... + ai >= aj
a1+.......+ai-1>= aj nu*/
s -= v[cnt].x;
if (v[cnt].y == 0)
nr--;
cnt--;
s += c;
if (tip == 0)
nr++;
cnt++;
v[cnt] = {c, tip};
}
if (s > k)
break;
}
if (s <= k)
{
if (ans.x < nr || (ans.x == nr && ans.y > s))
{
ans.x = nr;
ans.y = s;
}
}
cout << ans.x << '\n' << k - ans.y;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |