QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#878061 | #9692. Currency | ucup-team3584# | WA | 1ms | 3712kb | C++17 | 3.8kb | 2025-02-01 13:20:03 | 2025-02-01 13:20:10 |
Judging History
answer
#include <string.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> using vvvc = vector<vector<vector<T>>>;
template<class T> using pq = priority_queue<T,vector<T>,greater<T>>;
template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }
template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }
int dx4[] = {1,0,-1,0};
int dy4[] = {0,1,0,-1};
#define overload5(a, b, c, d, e, name, ...) name
#define overload4(a, b, c, d, name, ...) name
#define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf)
#define REP1(i, n) for(ll i = 0; i < (n); ++i)
#define REP2(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf)
#define per1(i, n) for(ll i = (n)-1; i >= 0; --i)
#define per2(i, a, b) for(ll i = (a)-1; i >= b; --i)
#define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c))
#define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define drop(s) cout << #s << endl, exit(0)
#define si(c) (int)(c).size()
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{}))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{}))
#define rng(v, l, r) v.begin() + (l), v.begin() + (r)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define SORT(v) sort(all(v))
#define REV(v) reverse(all(v))
#define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end())
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define overload2(_1, _2, name, ...) name
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
ll inf = 1001001001001001001;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin >> n >> m;
vc<int>a(n-1),b(n),c(n-1);
rep(i,n-1) {
cin >> a[i];
}
rep(i,n) {
cin >> b[i];
}
ll sum = 0;
rep(i,n-1) {
cin >> c[i];
sum += c[i];
}
vvc<pii>query(n);
rep(i,m) {
int U,V,C;
cin >> U >> V >> C;
U--;
V--;
if(U < V) {
query[U].pb({V,C});
}
}
vc<ll>sum2(n+1);
ll ans = inf;
rep(i,n) {
for(auto j:query[i]) {
sum2[i+1] += j.se;
sum2[j.fi+1] -= j.se;
}
sum2[i+1] += sum2[i];
chmin(ans,sum2[i]+sum+b[i]);
if(i+1 < n) {
sum -= c[i];
sum += a[i];
}
}
cout << ans << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
5 2 2 3 5 2 6 1 2 1 1 1 2 4 2 1 4 4 2 3 1
output:
13
result:
ok 1 number(s): "13"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
6 1000 601450612 529194719 287622428 350370653 2490001 267842805 909540874 518481012 265798837 15815265 20879824 142543426 589509572 795333485 574202609 686307559 5 5 368241593 3 4 501344156 3 2 881313477 5 3 877155507 3 3 638857659 3 5 60427320 3 1 888140066 1 1 820913164 3 2 656494106 5 2 48265697...
output:
1792008237
result:
ok 1 number(s): "1792008237"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
6 1000 939223353 592232256 204123592 697949032 283207645 247227259 860831362 710972139 170824074 510978702 280845746 896873779 377774668 7308887 326686740 179453061 2 3 997446049 2 3 519323074 4 1 939589279 2 5 98041599 4 4 869921378 3 3 558765317 1 2 483873583 5 1 33483163 3 3 270388480 4 4 5510784...
output:
2035324394
result:
ok 1 number(s): "2035324394"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
6 1000 959730384 933307890 88544023 434800479 519026844 598287106 88518137 220336188 475197957 997211224 13754116 615549399 359488030 322300660 426429747 456751804 2 1 37534981 2 1 826968454 4 5 736905082 2 2 392058437 3 2 148710959 5 3 340405411 4 3 756316407 1 1 989545410 1 4 953888522 1 2 4208087...
output:
2778806746
result:
ok 1 number(s): "2778806746"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
6 1000 828474485 450284805 615710614 642827608 358927789 340890875 324511822 431939488 283505035 960286257 744621984 19345807 677774542 254789794 431703631 752285873 4 1 619213429 4 2 475954933 2 1 372220764 4 3 365954206 5 2 66701266 5 5 715874448 2 1 385795225 2 4 215024198 2 3 335608279 4 5 81229...
output:
2476790522
result:
ok 1 number(s): "2476790522"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
6 1000 773101001 64230554 596335108 570954044 371802052 672297875 609818176 210924742 474129815 637532288 845662045 381562818 836547701 790875625 459034073 816120888 3 4 171273656 2 2 669511947 1 5 99209262 4 1 393105839 4 2 161297430 3 2 175654558 4 4 895979780 2 1 380318119 2 3 438246899 2 2 61661...
output:
3222084804
result:
ok 1 number(s): "3222084804"
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 3712kb
input:
6 1000 786204681 325567741 53406367 432402436 442330564 1353889 4683275 528413577 555907196 568518211 61420817 117239404 703766279 710007531 852547435 543311026 1 1 830934334 2 3 981865567 3 2 439871419 3 2 377106611 1 1 849647504 2 4 590590318 5 5 333563280 3 4 908162812 1 3 384002897 4 4 701562502...
output:
2101332606
result:
wrong answer 1st numbers differ - expected: '1438404493', found: '2101332606'