QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767700#9528. New Energy VehiclefruianWA 0ms3616kbC++141.5kb2024-11-20 21:47:462024-11-20 21:47:47

Judging History

This is the latest submission verdict.

  • [2024-11-20 21:47:47]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3616kb
  • [2024-11-20 21:47:46]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
#define endl "\n" 
#define int long long
#define sz(x) ((int)(x).size())
#define lowbit(x) ((x) & -(x))
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,x,y) for(int i = x;i<y;i++)
#define reb(i,x,y) for(int i = x;i<=y;i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
typedef long double ld;
const int N = 1e5+10, M = 2e7+10, mod = 998244353 , inf = 0x7fffffff;
const ld eps = 1e-12;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



inline void solve() {
    int n, m;
    cin>>n>>m;
    vector<int>a(n);
    int s = 0;
    rep(i,0,n){
        cin>>a[i];
        s += a[i];
    }
    vector<pii>tar(m);
    rep(i,0,m)cin>>tar[i].x>>tar[i].y;

    map<int, int> rem;
    int ud = 0;
    int now = 0;
    for(int i = 0;i<m;i++){
        int d = tar[i].x - now;
        if(d + ud > s)break;

        int f = min({d+ud, a[tar[i].y], tar[i].x-rem[tar[i].y]});
        rem[tar[i].y] = tar[i].x;
        now = tar[i].x;
        ud += d - f;
    }

    // cout<<ud<<endl;
    cout<<now + s - ud<<endl;
}

signed main(){
    IOS;
    cout << fixed << setprecision(10);
    int __ = 1;
    cin>>__;
    while(__--) {
        solve();
        // cout<<endl;
    }
    return 0;
}

详细

Test #1:

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

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

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
10
4
10
999999999
1000000000

result:

wrong answer 2nd lines differ - expected: '11', found: '10'