QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#686075 | #9528. New Energy Vehicle | SilverGodly | WA | 0ms | 3556kb | C++23 | 1.4kb | 2024-10-28 23:50:43 | 2024-10-28 23:50:44 |
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>pre(m + 5);
map<int,int>mp;
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];
pre[i] = mp[t[i]];
mp[t[i]] = i;
}
for(int i = 1;i<=m;i++){
if(dp[i - 1] + sum >= x[i]){
dp[i] = dp[i - 1] + min({dp[i - 1] - dp[pre[i]] + x[i] - x[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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3556kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
12 10
result:
wrong answer 2nd lines differ - expected: '9', found: '10'