ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214172 | #2031. a | erican | 10 | 138ms | 2736kb | C++11 | 2.7kb | 2024-11-15 21:30:03 | 2024-11-15 23:28:12 |
answer
/*
Keyblinds Guide
###################
@Ntsc 2024
- Ctrl+Alt+G then P : Enter luogu problem details
- Ctrl+Alt+B : Run all cases in CPH
- ctrl+D : choose this and dump to the next
- ctrl+Shift+L : choose all like this
- ctrl+K then ctrl+W: close all
- Alt+la/ra : move mouse to pre/nxt pos'
*/
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define rep(i, l, r) for (int i = l, END##i = r; i <= END##i; ++i)
#define per(i, r, l) for (int i = r, END##i = l; i >= END##i; --i)
#define pb push_back
#define mp make_pair
#define int long long
#define ull unsigned long long
#define pii pair<int, int>
#define ps second
#define pf first
// #define innt int
#define itn int
// #define inr intw
// #define mian main
// #define iont int
#define rd read()
int read(){
int xx = 0, ff = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
ff = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
xx = xx * 10 + (ch - '0'), ch = getchar();
return xx * ff;
}
void write(int out) {
if (out < 0)
putchar('-'), out = -out;
if (out > 9)
write(out / 10);
putchar(out % 10 + '0');
}
#define zerol = 1
#ifdef zerol
#define cdbg(x...) do { cerr << #x << " -> "; err(x); } while (0)
void err() { cerr << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cerr << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
const int N = 3e5 + 5;
const int INF = 1e18;
const int M = 1e7;
const int MOD = 1e9 + 7;
struct Node{
int l,r;
}t[N];
bool cmp(Node a,Node b){
if(a.r==b.r)return a.l<b.l;
return a.r<b.r;
}
inline int popcnt(int x){
int res=0;
while(x){
res+=x&1;
x>>=1;
}
return res;
}
int n;
int K;
int ans;
void check(int s){
int res=0;
int pre=0;
for(int i=0;i<n;i++){
if(s>>i&1)continue;
res+=t[i].r-max(t[i].l-1,pre);
pre=t[i].r;
}
ans=max(res,ans);
}
void solve(){
n=rd,K=rd;
for(int i=0;i<n;i++){
t[i].l=rd+1;
t[i].r=rd;
}
sort(t,t+n,cmp);
for(int i=0;i<(1<<n);i++){
if(popcnt(i)!=K)continue;
check(i);
}
cout<<ans<<endl;
}
signed main() {
// freopen(".in","r",stdin);
// freopen(".in","w",stdout);
int T=1;
while(T--){
solve();
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 23ms
memory: 1172kb
input:
20 8 941374267 958239792 636546050 949277063 30572593 458894768 377940690 585510776 595907552 909524...
output:
962953314
result:
wrong answer 1st lines differ - expected: '982023824', found: '962953314'
Test #2:
score: 10
Accepted
time: 16ms
memory: 1176kb
input:
20 15 76365869 433406218 633171333 786737074 131600137 929106040 44288699 688307921 419471992 769278...
output:
923804666
result:
ok single line: '923804666'
Test #3:
score: 0
Wrong Answer
time: 16ms
memory: 1172kb
input:
20 2 358841118 908572644 771680732 777280263 232627681 399317312 146158799 355582975 95552785 629032...
output:
682754809
result:
wrong answer 1st lines differ - expected: '898648766', found: '682754809'
Test #4:
score: 0
Wrong Answer
time: 2ms
memory: 1248kb
input:
5000 49 383739070 641316367 609140743 773905546 333655225 869528584 456526030 666877251 488787058 91...
output:
0
result:
wrong answer 1st lines differ - expected: '999604831', found: '0'
Test #5:
score: 0
Wrong Answer
time: 2ms
memory: 1248kb
input:
5000 56 6389143 923791616 594084401 918014476 192256209 434682769 125655174 766893261 348541120 7426...
output:
0
result:
wrong answer 1st lines differ - expected: '999844854', found: '0'
Test #6:
score: 0
Wrong Answer
time: 0ms
memory: 1248kb
input:
5000 63 206266865 481555569 431544412 914639759 535710313 662467481 77260492 436949450 208295182 418...
output:
0
result:
wrong answer 1st lines differ - expected: '999740177', found: '0'
Test #7:
score: 0
Wrong Answer
time: 20ms
memory: 2732kb
input:
100000 95 31394575 31395303 35035434 35036166 64896609 64897277 10992021 10992677 17899328 17900254 ...
output:
0
result:
wrong answer 1st lines differ - expected: '74878135', found: '0'
Test #8:
score: 0
Wrong Answer
time: 21ms
memory: 2732kb
input:
100000 83 233039267 233039367 916657359 916657459 864715109 864715209 936842396 936842496 562959930 ...
output:
0
result:
wrong answer 1st lines differ - expected: '9880370', found: '0'
Test #9:
score: 0
Wrong Answer
time: 15ms
memory: 2736kb
input:
100000 90 816642137 816642237 185449925 185450025 619425312 619425412 335954840 335954940 14523568 1...
output:
0
result:
wrong answer 1st lines differ - expected: '9879012', found: '0'
Test #10:
score: 0
Wrong Answer
time: 23ms
memory: 2732kb
input:
100000 85 932471751 932471851 591128329 591128429 632579047 632579147 902529780 902529880 377540930 ...
output:
0
result:
wrong answer 1st lines differ - expected: '9876663', found: '0'