QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#686057 | #9528. New Energy Vehicle | SilverGodly | WA | 1ms | 3780kb | C++23 | 1.2kb | 2024-10-28 23:35:17 | 2024-10-28 23:35:18 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return 1ll * a * b / gcd(a, b); }
ll divCeil(ll x, ll y) { return x / y + (x % y != 0); }
const int MAXN = 2e5 + 5;
const double pi = 3.14159265358979323846;
const ll inf = 1e18;
double eps = 1e-9;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
#define endl "\n"
#define int long long
void solve() {
int n,m;
cin >> n >> m;
vector<int>a(n + 5);
vector<int>dp(m + 5);
vector<int>x(m + 5);
vector<int>t(m + 5);
int sum = 0;
for(int i = 1;i<=n;i++){
cin >> a[i];
sum += a[i];
}
for(int i = 1;i<=m;i++){
cin >> x[i] >> t[i];
}
for(int i = 1;i<=m;i++){
if(dp[i - 1] + sum >= x[i]){
dp[i] = dp[i - 1] + min(x[i] - dp[i - 1],a[t[i]]);
}
else{
cout << dp[i - 1] + sum << endl;
return;
}
}
cout << dp[m] + sum << endl;
return;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
while (t--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3780kb
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: 3544kb
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:
10 11 4 11 999999999 2000000000
result:
wrong answer 1st lines differ - expected: '9', found: '10'