Submission #60156837
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
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;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N=1010000;
int n;
int a[N],b[N];
array<ll,3> solve(int l,int r) {
if (l==r) {
return {(ll)0,(ll)a[l],(ll)b[l]};
} else {
int md=(l+r)>>1;
auto r1=solve(l,md);
auto r2=solve(md+1,r);
ll p1=max(r1[1],r2[1]),p2=min(r1[2],r2[2]);
if (p1<=p2) {
return {r1[0]+r2[0],p1,max(r1[2],r2[2])};
} else {
if (r1[1]>r2[1]) swap(r1,r2);
return {r1[0]+r2[0]+r2[1]-r1[2],r2[1],r2[2]};
}
}
}
int main() {
scanf("%d",&n);
rep(i,0,1<<n) scanf("%d%d",&a[i],&b[i]);
auto ret=solve(0,(1<<n)-1);
printf("%lld\n",ret[0]);
}
Submission Info
Submission Time |
|
Task |
A - Schedule Optimization |
User |
apiad |
Language |
C++ 20 (gcc 12.2) |
Score |
0 |
Code Size |
1274 Byte |
Status |
WA |
Exec Time |
56 ms |
Memory |
5932 KB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:44:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
44 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
Main.cpp:45:28: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
45 | rep(i,0,1<<n) scanf("%d%d",&a[i],&b[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 900 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_srand_00.txt, 01_srand_01.txt, 01_srand_02.txt, 01_srand_03.txt, 01_srand_04.txt, 01_srand_05.txt, 01_srand_06.txt, 01_srand_07.txt, 01_srand_08.txt, 01_srand_09.txt, 02_lrand_00.txt, 02_lrand_01.txt, 02_lrand_02.txt, 02_lrand_03.txt, 02_lrand_04.txt, 02_lrand_05.txt, 02_lrand_06.txt, 02_lrand_07.txt, 02_lrand_08.txt, 02_lrand_09.txt, 02_lrand_10.txt, 02_lrand_11.txt, 02_lrand_12.txt, 02_lrand_13.txt, 02_lrand_14.txt, 02_lrand_15.txt, 02_lrand_16.txt, 02_lrand_17.txt, 02_lrand_18.txt, 02_lrand_19.txt, 03_short_00.txt, 03_short_01.txt, 03_short_02.txt, 03_short_03.txt, 03_short_04.txt, 03_short_05.txt, 03_short_06.txt, 03_short_07.txt, 04_hand_00.txt, 04_hand_01.txt, 04_hand_02.txt, 04_hand_03.txt, 04_hand_04.txt, 04_hand_05.txt, 04_hand_06.txt, 04_hand_07.txt, 05_same_00.txt, 05_same_01.txt, 05_same_02.txt, 05_same_03.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
1 ms |
3820 KB |
00_sample_01.txt |
AC |
1 ms |
3580 KB |
00_sample_02.txt |
AC |
1 ms |
3820 KB |
01_srand_00.txt |
AC |
1 ms |
3684 KB |
01_srand_01.txt |
AC |
1 ms |
3628 KB |
01_srand_02.txt |
AC |
1 ms |
3820 KB |
01_srand_03.txt |
AC |
1 ms |
3628 KB |
01_srand_04.txt |
AC |
1 ms |
3648 KB |
01_srand_05.txt |
WA |
1 ms |
3692 KB |
01_srand_06.txt |
AC |
1 ms |
3628 KB |
01_srand_07.txt |
AC |
1 ms |
3880 KB |
01_srand_08.txt |
WA |
1 ms |
3816 KB |
01_srand_09.txt |
WA |
1 ms |
3688 KB |
02_lrand_00.txt |
WA |
54 ms |
5728 KB |
02_lrand_01.txt |
WA |
56 ms |
5736 KB |
02_lrand_02.txt |
WA |
53 ms |
5868 KB |
02_lrand_03.txt |
WA |
53 ms |
5672 KB |
02_lrand_04.txt |
WA |
54 ms |
5932 KB |
02_lrand_05.txt |
WA |
53 ms |
5876 KB |
02_lrand_06.txt |
WA |
53 ms |
5928 KB |
02_lrand_07.txt |
WA |
54 ms |
5932 KB |
02_lrand_08.txt |
WA |
53 ms |
5796 KB |
02_lrand_09.txt |
WA |
54 ms |
5928 KB |
02_lrand_10.txt |
WA |
27 ms |
4708 KB |
02_lrand_11.txt |
WA |
27 ms |
4900 KB |
02_lrand_12.txt |
WA |
27 ms |
4708 KB |
02_lrand_13.txt |
WA |
27 ms |
4652 KB |
02_lrand_14.txt |
WA |
28 ms |
4708 KB |
02_lrand_15.txt |
WA |
27 ms |
4704 KB |
02_lrand_16.txt |
WA |
27 ms |
4648 KB |
02_lrand_17.txt |
WA |
28 ms |
4900 KB |
02_lrand_18.txt |
WA |
27 ms |
4708 KB |
02_lrand_19.txt |
WA |
27 ms |
4848 KB |
03_short_00.txt |
WA |
29 ms |
4652 KB |
03_short_01.txt |
WA |
56 ms |
5808 KB |
03_short_02.txt |
WA |
55 ms |
5732 KB |
03_short_03.txt |
WA |
55 ms |
5732 KB |
03_short_04.txt |
WA |
28 ms |
4852 KB |
03_short_05.txt |
WA |
15 ms |
4196 KB |
03_short_06.txt |
WA |
55 ms |
5728 KB |
03_short_07.txt |
WA |
14 ms |
4196 KB |
04_hand_00.txt |
AC |
28 ms |
5732 KB |
04_hand_01.txt |
AC |
14 ms |
4908 KB |
04_hand_02.txt |
WA |
56 ms |
5868 KB |
04_hand_03.txt |
WA |
55 ms |
5672 KB |
04_hand_04.txt |
WA |
55 ms |
5744 KB |
04_hand_05.txt |
WA |
55 ms |
5728 KB |
04_hand_06.txt |
WA |
55 ms |
5676 KB |
04_hand_07.txt |
WA |
55 ms |
5816 KB |
05_same_00.txt |
AC |
1 ms |
3684 KB |
05_same_01.txt |
AC |
1 ms |
3632 KB |
05_same_02.txt |
AC |
1 ms |
3900 KB |
05_same_03.txt |
AC |
33 ms |
5748 KB |