QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#686340 | #9528. New Energy Vehicle | AI80 | WA | 1ms | 5892kb | C++20 | 1011b | 2024-10-29 11:31:41 | 2024-10-29 11:31:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lowbit(x) (x & (-x))
#define lc p << 1
#define rc p << 1 | 1
typedef long long ll;
typedef pair<int,int> pii;
mt19937 rnd(time(0));
const int N = 3e5 + 7;
const int mod = 1e9 + 7;
int tree[N],a[N];
pii c[N];
void solve() {
int now = 0;
int n , m; cin >> n >> m;
for(int i = 1;i <= n;i++) cin >> a[i],now += a[i];
for(int i = 1;i <= m;i++) cin >> c[i].first >> c[i].second;
sort(c + 1,c + m + 1);
int ans = 0;
for(int i = 1;i <= m;i++) {
if(now < c[i].second - c[i].first) {
cout << ans + now << "\n";
return ;
}
ans += c[i].first - c[i - 1].first;
now -= c[i].first - c[i - 1].first;
now += min(c[i].first - c[i - 1].first,a[c[i].second]);
}
cout << ans + now << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while(t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5764kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
12 9
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5892kb
input:
6 3 2 2 2 2 6 1 7 1 2 2 3 3 2 1 6 2 2 3 2 2 5 1 7 2 9 1 2 2 3 3 2 1 6 2 1 1 999999999 1000000000 1 1 1 1000000000 1000000000 1
output:
9 11 10 11 1999999998 2000000000
result:
wrong answer 3rd lines differ - expected: '4', found: '10'