QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#796793#6564. Frequent Flierzeyu#WA 24ms4984kbC++232.3kb2024-12-02 04:16:412024-12-02 04:16:42

Judging History

你现在查看的是最新测评结果

  • [2024-12-02 04:16:42]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:4984kb
  • [2024-12-02 04:16:41]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pl pair<ll, ll>
#define pi pair<int, int>
#define minpq priority_queue<ll, vector<ll>, greater<ll>>
using namespace std;

#if 1
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '['; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "]";}
void _print() {cerr << endl << flush;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "*["<<__LINE__<<"]\t"<< #x << " = "; _print(x)
#endif

const ll mod = 1e9 + 7;

template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll gcd(ll a, ll b) {if(b == 0){return a;} return gcd(b, a % b);}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, m, k; cin >> n >> m >> k;
	vector<ll> a(n + m); for (int i = 0; i < n; i ++) cin >> a[i + m];
	n += m;
	ll ans = 0, cnt = 0;
	set<pl> s;
	for (ll i = 0; i < n; i ++){	
		s.insert({i, a[i]});
		cnt += a[i]; 
		if (s.size() > m){
			pl p = *s.begin();
			cnt -= p.se;
			ans += p.se;
			s.erase(p);
		}
		if (s.size() == m){
			while(cnt > k){
				pl p = *s.begin();
				s.erase(p);
				if (cnt - p.se < k){
					s.insert({p.fi, p.se - (cnt - k)});
					cnt = k;
				} else{
					cnt -= p.se;
				}
			}
		}
	}
	cout << ans + cnt << '\n';
}

/*
Do something instead of nothing!
Print out stuffs / study samples when you cannot find the bug!
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3736kb

input:

8 3 2
3
1
4
1
5
9
2
6

output:

8

result:

ok single line: '8'

Test #2:

score: -100
Wrong Answer
time: 24ms
memory: 4984kb

input:

200000 2467 999931035
182548858
69876218
33328350
919486767
739850600
948199964
392292320
39077742
366752074
917496841
246661698
37219034
56677740
188278971
965701828
28059790
13200243
825730775
542597589
320715170
939054378
470563899
914247467
990100491
290827128
903662394
611104879
18631185
412134...

output:

189487983335

result:

wrong answer 1st lines differ - expected: '82994275905', found: '189487983335'