Tue, 12 Feb 2019 12:05:32 GMT

master
大蒟蒻 7 years ago
parent 270593f584
commit 736458fdf0

@ -79,3 +79,11 @@ multiset搞一下又忘记clear了
### Q - Lineland Mail
超级无敌水题。。。。。
### R - Berland National Library
水题
### S - Producing Snow
multiset加前缀和

@ -2,7 +2,29 @@
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 50;
bool in[N];
int ans, cnt;
int main()
{
int n;
scanf("%d", &n);
while (n--)
{
char buf[3];
int id;
scanf("%s%d", buf, &id);
if (*buf == '+')
{
in[id] = true;
ans = max(ans, ++cnt);
}
if (*buf == '-')
{
if (in[id]) in[id] = false, cnt--;
else ans++;
}
}
printf("%d", ans);
return 0;
}

@ -2,7 +2,26 @@
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
typedef long long ll;
ll v[N], t[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%lld", v + i);
for (int i = 1; i <= n; i++) scanf("%lld", t + i);
for (int i = 1; i <= n; i++) t[i] += t[i - 1];
for (int i = 1; i <= n; i++) v[i] += t[i - 1];
multiset<ll> s;
for (int i = 1; i <= n; i++)
{
s.insert(v[i]);
ll ans = 0;
while (!s.empty() && *s.begin() <= t[i])
ans += *s.begin() - t[i - 1], s.erase(s.begin());
ans += (t[i] - t[i - 1]) * s.size();
printf("%lld ", ans);
}
return 0;
}

Loading…
Cancel
Save