QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#796789 | #6564. Frequent Flier | zeyu# | WA | 29ms | 5076kb | C++23 | 2.3kb | 2024-12-02 04:08:15 | 2024-12-02 04:08:15 |
Judging History
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); for (int i = 0; i < n; i ++) cin >> a[i];
ll ans = 0, cnt = 0;
set<pl> s;
for (ll i = 0; i < n; i ++){
s.insert({i, a[i]});
cnt += a[i];
ans += a[i];
if (s.size() > m){
pl p = *s.begin();
cnt -= p.se;
}
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)});
ans -= cnt - k;
cnt = k;
} else{
ans -= p.se;
cnt -= p.se;
}
}
}
}
cout << ans << '\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: 3644kb
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: 29ms
memory: 5076kb
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'