QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#674910#9528. New Energy Vehicleytck#WA 0ms3592kbC++171.7kb2024-10-25 17:40:122024-10-25 17:40:13

Judging History

This is the latest submission verdict.

  • [2024-10-25 17:40:13]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3592kb
  • [2024-10-25 17:40:12]
  • Submitted

answer

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0),cout.tie(0)
#define endl '\n'
#define PII pair<int, int>
#define int long long
//#define int __int128
using namespace std;
inline int read();
inline void write(int x);
const int N = 1e5 + 10, M = 2e3 + 10, mod = 998244353, inf = 1e18, base = 131;
const double eps = 1e-7;
int n, m;
void solve(){
    cin >> n >> m;
    vector<int> p(n + 10, 0);
    vector<PII> f(m + 10, {0, 0});
    int sum = 0, res;
    for(int i = 1; i <= n; i++){
        cin >> p[i];
        sum += p[i];
    }
    res = sum;
    for(int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        f[i] = {a, b};
    }
    int dv = 0;
    for(int i = 1; i <= m; i++){
        int b = f[i].second;
        int len = f[i].first - f[i - 1].first;
        if(len > p[b]){
            dv += (len - p[b]);
            if(dv > sum - p[b]){
                dv -= (len - p[b]);
                cout << f[i - 1].first + (sum - dv);
                return;
            }
        }
        else{
            int d = p[b] - len;
            dv -= min(dv, d);
        }
    }
    cout << f[m].first + (sum - dv) << endl;
    
}
signed main() {
    IOS;
    int T = 1;
    cin >> T;
    while (T--){
        solve();
    }
}
inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
    return x * f;
}
inline void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3520kb

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: 3592kb

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
411
9999999992000000000

result:

wrong answer 1st lines differ - expected: '9', found: '10'