QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#632245 | #9450. Balloon Robot | ucup-team055# | AC ✓ | 96ms | 4764kb | C++20 | 2.3kb | 2024-10-12 13:06:26 | 2024-10-12 13:06:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll ILL=2167167167167167167;
const int INF=2100000000;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
bool yneos(bool a,bool upp=0){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;}
template<class T> void vec_out(vector<T> &p,int ty=0){
if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'<<p[i]<<'"';}cout<<"}\n";}
else{if(ty==1){cout<<p.size()<<"\n";}for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}}
template<class T> T vec_min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T vec_max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}
template<class T> T vec_sum(vector<T> &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;}
int pop_count(long long a){int res=0;while(a){res+=(a&1),a>>=1;}return res;}
template<class T> bool inside(T l,T x,T r){return l<=x&&x<r;}
void solve();
// CYAN / FREDERIC
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
rep(i, 0, t) solve();
}
void solve(){
ll N, M, P;
cin >> N >> M >> P;
vector<ll> S(N);
rep(i, 0, N) cin >> S[i], S[i]--;
vector<ll> A(P);
rep(i, 0, P){
ll a, b;
cin >> a >> b;
a = S[a - 1];
A[i] = ((a - b) % M + M) % M;
}
So(A);
ll tmp = vec_sum(A);
ll ans = tmp;
ll F = 0;
rep(i, 0, P){
tmp -= (A[i] - F) * P;
chmin(ans, tmp);
tmp += M;
F = A[i];
}
cout << ans << "\n";
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
4 2 3 3 1 2 1 1 2 1 1 4 2 3 5 1 2 1 1 2 1 1 2 1 3 1 4 3 7 5 3 5 7 1 5 2 1 3 3 1 5 2 5 2 100 2 1 51 1 500 2 1000
output:
1 4 5 50
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 96ms
memory: 4764kb
input:
1004 22 9426 26 1165 5248 8331 9055 1161 7381 2188 7489 5131 8434 2166 3981 6302 7188 4858 856 7797 9129 7839 1676 25 9053 20 6 22 68 12 16 11 63 17 49 5 10 21 68 17 80 18 18 10 28 15 55 14 80 1 45 21 67 5 74 13 4 3 34 7 80 9 95 5 52 8 31 2 53 7 22 5 99 20 66 12 2 33 9526 92 558 7460 280 7952 5186 9...
output:
94067 360219 223074 30971 171844 312753 0 158169 294738 291604 115632 59327 221328 287851 30518 337118 181724 249419 66367 10347 208411 180496 287130 40736 264604 278208 33792 191523 111583 31867 21143 232153 149868 191831 238832 63626 258936 133059 105618 237774 53942 342921 275883 110295 149350 20...
result:
ok 1004 lines
Extra Test:
score: 0
Extra Test Passed