QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711537 | #9528. New Energy Vehicle | ucup-team1329# | WA | 0ms | 3560kb | C++17 | 2.6kb | 2024-11-05 11:55:52 | 2024-11-05 11:55:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define all1(x) x.begin() + 1, x.end()
#define bit1(x) __builtin_popcountll(x)
#define Pqueue priority_queue
#define lc p << 1
#define rc p << 1 | 1
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define fi first
#define se second
#define lowbit(x) (x & -x)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const ll mod = 1000000007;
const ll N = 1e6 + 10;
const ld eps = 1e-9;
const ll inf = 1e18;
const ll P = 131;
const ll dir[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};
void solve()
{
int n, m;
cin >> n >> m;
vector<ll> a(n + 1);
for (int i = 1; i <= n; i++)
cin >> a[i];
ll tot = 0;
vector<ll> x(m + 1), t(m + 1);
for (int i = 1; i <= m; i++)
{
cin >> x[i] >> t[i];
tot += a[t[i]];
}
for (int i = m; i > 1; i--)
x[i] = x[i] - x[i - 1];
ll sum = 0, pos = 0;
for (int i = 1; i <= m; i++)
{
pos += x[i];
if (sum + x[i] <= tot)
{
sum = max(0ll, sum + x[i] - a[t[i]]);
}
else
{
cout << pos + tot - sum + 1 << "\n";
return;
}
}
cout << pos + tot - sum<< "\n";
}
/*
2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1
*/
int main()
{
IOS int T = 1;
cin >> T;
while (T--)
solve();
return 0;
}
/*
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
x o
o _/_/_/_/ _/ x
x _/ o
o _/_/_/_/ _/ _/_/ _/_/ _/_/_/ _/_/ _/_/_/ _/_/ _/_/_/ _/ _/ _/ x
x _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ o
o _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ x
x _/ _/ _/_/ _/ _/ _/ _/_/_/ _/_/ _/ _/ _/ _/ _/ o
o _/ _/ _/ x
x _/ _/_/ _/ o
o x
xoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxo
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
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: 0ms
memory: 3540kb
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:
11 11 12 11 2000000000 2000000000
result:
wrong answer 1st lines differ - expected: '9', found: '11'