# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
395442 | PanTkd | Bitwise (BOI06_bitwise) | C++14 | 2 ms | 320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// main.cpp
//
// Created by Panagiotis Chadjicostas on
// Copyright © Panagiotis Hadjicostas. All rights reserved.
//
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define fo(i,a,b) for(int i = a; i<=b; i++)
#define f(i,b) for(int i=0;i<b;i++)
#define F first
#define S second
#define sz size
const ll MOD=ll(1e9)+7;
const ll MAXN=2*ll(1e6);
///////////////////////////////////////////////////////////////////////
struct po{
ll s,e;
};
ll sc[1000];
ll l[1000];
void solve(){
ll n,p;cin>>n>>p;
for(ll i=1;i<=p;i++){
cin>>l[i];l[i]+=l[i-1];
}
po v[n+1];
for(ll i=1;i<=n;i++){
cin>>v[i].s>>v[i].e;
}
ll sol=0;
for(ll i=30;i>=0;i--){
bool ok=1;
ll put=(1<<i);
for(ll b=1;b<=p&&ok;b++){
sc[b]=0;
ok=false;
for(ll j=l[b-1]+1;j<=l[b];j++){
if(v[j].e>=put&&(v[j].s>=put||!sc[b])){
ok=true;
sc[b]=j;
}
}
}
if(ok){
sol += put;
for (ll b = 1; b <= p; b++)
v[sc[b]].s = max(v[sc[b]].s, put);
}
for(ll j=1;j<=n;j++){
if(v[j].s>=put){
v[j].s-=put;
v[j].e-=put;
}
else if (v[j].e>=put){
v[j].e=put-1;
}
}
}
cout<<sol<<endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t=1;//cin>>t;
while (t--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |