QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#567883 | #7973. 括号 | ASnown | 15 | 7ms | 4272kb | C++14 | 1.3kb | 2024-09-16 14:28:38 | 2024-09-16 14:28:39 |
Judging History
answer
#include<bits/stdc++.h>
#define file(F) freopen(#F".in","r",stdin),freopen(#F".out","w",stdout)
#define lowbit(x) ((x)&-(x))
#define ALL(x) x.begin(),x.end()
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define popcount(x) (__builtin_popcount((x)))
using namespace std;
using ll=long long;
using uint=uint32_t;
template<typename T>
inline bool Max(T &x,T y) { return std::less<T>()(x,y)&&(x=y,true); }
template<typename T>
inline bool Min(T &x,T y) { return std::less<T>()(y,x)&&(x=y,true); }
void Solve();
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int N = 2e2+22;
int n,Q;
int a[N];
char s[N];
ll f[N][N];
signed main() {
#ifndef ONLINE_JUDGE
#endif
cin.tie(nullptr)->sync_with_stdio(false);
Solve();
}
void Solve() {
cin>>n>>Q,n<<=1;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) cin>>s[i];
memset(f,0x3f,sizeof f);
f[0][0]=0;
for(int i=1;i<=n;i++) for(int j=0;j<=n;j++)
f[i][j]=min((j>0?f[i-1][j-1]+(s[i]=='('?0:a[i]):INF)
,(j<n?f[i-1][j+1]+(s[i]==')'?0:a[i]):INF));
printf("%lld\n",f[n][0]);
while(Q--) {
int x,y; cin>>x>>y;
a[x]=y;
for(int i=1;i<=n;i++) for(int j=0;j<=n;j++)
f[i][j]=min((j>0?f[i-1][j-1]+(s[i]=='('?0:a[i]):INF)
,(j<n?f[i-1][j+1]+(s[i]==')'?0:a[i]):INF));
printf("%lld\n",f[n][0]);
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 7ms
memory: 4192kb
input:
100 100 655884441 790777510 663667368 332762945 67681448 458058488 445481314 200508190 812326927 374891900 320371513 765529851 490260632 588113266 286392696 888016940 214376080 894477437 944447014 386015667 956960774 692332579 606560669 561835357 887377361 130572961 550186106 193341110 4130416 66982...
output:
1883520337 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 1938040724 193...
result:
ok 101 lines
Test #2:
score: 15
Accepted
time: 7ms
memory: 4212kb
input:
100 100 833141622 854468469 367770104 350280219 461621010 985561079 287746098 833893180 365597420 618761946 416883128 838478689 419500348 996463737 903782689 176582886 101963967 728502271 222282338 808921916 744579730 171837013 508527221 141613052 233501822 501818380 143462266 206528940 451714614 68...
output:
140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 140782913 ...
result:
ok 101 lines
Test #3:
score: 15
Accepted
time: 7ms
memory: 4272kb
input:
100 100 897203289 398741091 737994838 918141180 881683740 708870393 569981059 825462339 575892019 654430241 400748227 892258264 55868417 318639212 157441109 208939722 240809609 552556736 89466637 625250145 859111121 925840769 588412874 550260548 581965340 250456136 598142176 155996841 785774919 7347...
output:
16311332636 16311332636 16483179675 16483179675 16483179675 16891186615 16891186615 16891186615 17128610519 17533284483 17533284483 17533284483 17350707595 17252386332 16872696130 16872696130 16872696130 16854944528 16854944528 16854944528 16455983084 16455983084 16455983084 16450177820 16520502221 ...
result:
ok 101 lines
Test #4:
score: 15
Accepted
time: 7ms
memory: 4188kb
input:
100 100 779493178 536060978 737064866 935658454 907027082 236372983 485874770 753814620 129162512 898300287 907325259 965207103 690140842 432022392 406234882 497505669 791961008 755177790 662269254 416752612 983166566 478974131 490379426 835070952 928089802 548072627 191418336 832748183 896922627 38...
output:
10068455511 10068455511 9859559743 9859559743 9832855564 9869366615 9869366615 9869366615 9869366615 9869366615 9869366615 10090141889 10090141889 10090141889 10090141889 10090141889 9921505636 9921505636 9921505636 9921505636 10012459628 10312147623 10678895964 10678895964 10678895964 10621969654 1...
result:
ok 101 lines
Subtask #2:
score: 0
Runtime Error
Test #5:
score: 0
Runtime Error
input:
1000 1000 851064227 277152131 421722407 126468670 510326499 619107836 287335428 653386549 173788833 304176934 21753544 293653999 493165671 887566717 813114839 976556173 459946448 939807420 605205411 920860669 545229689 895277168 777349694 126341157 564711820 892644312 314220085 125767094 816813109 9...
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Runtime Error
Test #14:
score: 0
Runtime Error
input:
1000 1000 49658 21707 94558 56676 18487 74906 55206 78654 54538 14591 105694 138 3148 106151 90191 67461 90337 86524 39272 78899 111590 3181 67245 47146 1958 34378 6544 74125 93643 44483 2159 16309 41619 24332 1519 85340 25811 55827 51528 89913 71355 103446 97370 44299 107887 105014 44419 62592 1965...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #3:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%