Search is not available for this dataset
name stringlengths 2 88 | description stringlengths 31 8.62k | public_tests dict | private_tests dict | solution_type stringclasses 2
values | programming_language stringclasses 5
values | solution stringlengths 1 983k |
|---|---|---|---|---|---|---|
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int n, m; cin >> n >> m;
vector<int> imos(n + 2, 0);
for(int i = 0; i < m; i++){
int c, d; cin >> c >> d;
if(c < d){
imos[c]++;
imos[d]--;
}
}
for(int i = 1; i <= n + 1; i++){
imos[i] +... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | /*************************************************************************
> File Name: 3.cpp
> Author: cy
> Mail: 1002@qq.com
> Created Time: 15/5/13 20:28:00
************************************************************************/
#include<iostream>
#include<cstring>
#include <algorithm>
#include<... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <stack>
using namespace... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int IINF = INT_MAX;
void chmin(int &a, int b){a=min(a,b);};
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n+2, n+1);
vector<vector<int> > dp(n+2, vector<int>(n+2, IINF/2));
for(int i=0;i<m;i++){
int c, d;
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int N, m;
cin >> N >> m;
vector< bool > shop(N + 1, 0);
for(int i = 0; i < m; ++i){
int c, d;
cin >> c >> d;
fill( shop.begin() + c, shop.begin() + d, true);
}
cout << N + 1 + count(shop.begin(), shop.end(), true) * 2 << endl;
} |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL I... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
struct Range{
int s,e;
Range(){}
Range(int s... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;
int dp[510], nxt[510];
int main(){
int n, m;
cin >> n >> m;
vector<P> d(m);
rep(i, 0, m){
cin >> d[i].first >> d[i].second;
}
sort(d.begin(), d.e... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
#include <utility>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
int solve(void);
int main(void)
{
while (solve())
{
}... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int N, m;
int cum[1010];
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(10);
cin >> N >> m;
for (int i = 0; i < m; i++) {
int c, d;
cin >> c >> d;
cum[c]+... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF 1e9
#define INFLL 1e18
#define EPS 1e-9
#define REP(i,n) for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n) for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#de... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
/**
* Shopping
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Str... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
int n, m;
int table[2000];
int ans;
int main(){
scanf("%d%d",&n,&m);
ans = n+1;
rep(i,m){
int c, d;
scanf("%d%d",&c,&d);
table[c]++;
table[d]--;
}
for(int i = 1; i < 2000; i++) table[i] += table[i-1];
for(int i = ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
using namespace std;
int N,M;
int r[1010] = {};
int main(){
cin >> N >> M;
int c,d;
for(int i=1;i<=M;i++){
cin >> c >> d;
r[c+1]++; r[d+1]--;
}
for(int i=1;i<=N;i++) r[i] += r[i-1];
int ans = 0;
for(int i=1;i<=N;i++){
if(r[i]>=1) ans += 3;... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typed... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<cstdio>
using namespace std;
bool rev[1010];
int main(){
int n,m,c,d,ans;
scanf("%d%d",&n,&m);
while(m--){
scanf("%d%d",&c,&d);
for(int i=c;i<d;i++) rev[i]=true;
}
ans=n+1;
for(int i=1;i<n;i++) if(rev[i]) ans+=2;
printf("%d\n",ans);
return 0;
} |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
boolean[] triple = new boolean[n];
for (int i = 0; i < m; i++) {
int c = sc.nextInt();
int d = sc.nextInt();
for (int j = c; j <... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<stdio.h>
#include<algorithm>
using namespace std;
int p[1100];
int main(){
int a,b;scanf("%d%d",&a,&b);
for(int i=0;i<a;i++){
int c,d;
scanf("%d%d",&c,&d);
for(int i=c;i<d;i++)p[i]++;
}
int ret=a+1;
for(int i=1;i<=a;i++)if(p[i])ret+=2;
printf("%d\n",ret);
} |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> pii;
int main() {
int n, m;
cin ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
void printv(vector<ll> v) {
for (ll i : v)
cout << i << endl;
}
int main() {
int n, m;
cin >> n >> m;
vector<int> st(n + 1, 1);
rep(... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
typedef long long int i64;
typedef pair<int, int> pint;
int a[1001];
int main() {
int N, M; scanf("%d%d", &N, &M);
int c, d;
memset(a, 0, sizeof(a));
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, n... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(S... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | java | import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.Function;
public class Main {
static int N, M;
static int[] C, D;
public static void main(String[] args) {
FastScanner sc = new FastSc... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
int main() {
int N, m;
int c[2048];
int d[2048];
int imos[2048] = {};
std::cin >> N >> m;
for(int i = 0; i < m; ++i) {
std::cin >> c[i] >> d[i];
}
for(int i = 0; i < m; ++i) {
imos[c[i]] += 1;
imos[d[i]] -= 1;
}
int t = 0;
for(int i = 0; i <= N; ++i) {
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <cstdio>
#include <algorithm>
using std::sort;
using std::max;
struct shop{
int l, r;
}shops[1000];
int S;
bool comp(shop a, shop b){
return a.l < b.l;
}
int main(){
int N, M;
scanf("%d %d", &N, &M); N++;
while(M--){
int l, r;
scanf("%d %d", &l, &r);
if(l < r){
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m; cin >> n >> m;
vector<pair<int, int>> rng(m);
for (auto &p: rng) cin >> p.first >> p.second, p.first--, p.second--;
rng.emplace_back(0, 0); rng.emplace_back(n, n);
sort(rng.begin(), rng.end());
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> vi;
typedef vector<vi> vvi;
typed... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int N, m;
cin >> N >> m;
vector<int> c(m), d(m);
for (int i = 0; i < m; i++){
cin >> c[i] >> d[i];
}
vector<int> cnt(N + 1, 0);
for (int i = 0; i < m; i++){
for (int j = c[i]; j < d[i]; j++){
cnt[j]++;
}
}
int ans = N + 1;
f... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,a,b;
vector<P> t,u;
vector<P> func(vector<P> t){
sort(t.begin(),t.end());
t.push_back(P(1e9,0));
int size=t.size();
vector<P> res;
for(int i=0;i+1<size;i++){
if(t[i].second<t[i+1].first){
res.push_back(t[i]);
}else{
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int main(void)
{
int n,m;
cin >> n >> m;
int bac[1024]={};
REP(i,m){
int c,d;
cin >> c >> d;
bac[d-1]++;
bac[... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<iostream>
#include<list>
#include<string>
#include<algorithm>
#include <utility>
#include<stdio.h>
#include<climits>
using namespace std;
int main(void){
int n,m;
int c,d;
int f[1000] = {};
cin >> n >> m;
int i,j;
for(i = 0;i < m;i++){
cin >> c >> d;
for(j = c;j < d;j+... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<iostream>
using namespace std;
int main(){
int n,m;
cin >> n >> m;
int p[1050]={};
int i,j,k;
for(i=0;i<m;i++){
cin >> j >> k;
p[j]=max(p[j],k);
}
int inf = 1<<15;
int dp[1050][1050];
fill(dp[0],dp[1049],inf);
dp[0][0]=0;
i=0;
for(j=max(i+1,p[i+1]);j<=n+1;j++){
dp[j][i+1]=mi... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typed... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include"bits/stdc++.h"
using namespace std;
using ll = int64_t;
int main() {
ll N, m;
cin >> N >> m;
vector<ll> restricts(N, -1);
for (int i = 0; i < m; i++) {
ll c, d;
cin >> c >> d;
c--; d--;
restricts[c] = max(restricts[c], d);
}
ll ans = 0;
ll left = IN... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
int n,m;
bool b[3000]={};
int main(){
cin>>n>>m;
while(m--){
int l,r;
cin>>l>>r;
for(int i=l;i<r;i++){
b[i]=true;
}
}
int ans=0;
for(int i=0;i<n+1;i++){
if(b[i]) ans+=3;
else ans++;
}
cout<<ans<<endl;
}
|
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
int main() {
int N,m; cin >> N >> m;
vector<int>backs(N, false);
for (int i = 0; i < m; ++i) {
int t, f; cin >> t ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,M;
cin >> N >> M;
vector< pair<int,int> > e;
int ans = N + 1 ;
for(int i = 0 ; i < M ; i++){
int a,b;
cin >> a >> b;
e.push_back(make_pair(a,b));
}
if( M == 0 ){
cout << ans << endl;
return 0;
}
sort(e.begin(),e.end());
int le = e[0].... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | python3 | N, m = map(int, input().split())
v = [0]*N
for i in range(m):
c, d = map(int, input().split())
v[c-1] += 1
v[d-1] -= 1
s = 0; fst = 0
ans = N+1
for i in range(N):
if s == 0 and v[i] > 0:
fst = i
s += v[i]
if s == 0 and v[i] < 0:
ans += (i - fst)*2
print(ans) |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
#define int long long // <-----!!!!!!!!!!!!!!!!!!!
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef uns... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
using namespace std;
typedef long l... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAX 600
struct rest{
int start, end;
inline void set(int a, int b){ start = a; end = b; }
bool operator < (const rest &a) const { return end < a.end; }
} rests[MAX];
int n, m, restlen;
bool exist[MAX];
int main(){
int a, b... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD ((int)1e9+7)
#define MAX 2000
int N, m, ans;
int c[MAX], d[MAX];
int temp[MAX];
signed main(){
cin>>N>>m;
for(int i = 0; i < m; i++){
cin>>c[i]>>d[i];
temp[c[i]]++;
temp[d[i]]--;
}
for(int i = 0; i <= N; i++){
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <cstdio>
int n,m;
int c[501],d[501];
int cnt[1001];
int main(void){
scanf("%d %d",&n,&m);
for(int i=0;i<m;i++){
scanf("%d %d",&c[i],&d[i]);
for(int j=c[i];j<d[i];j++){
cnt[j]=1;
}
}
int res=n+1;
for(int i=0;i<=n;i++){
res+=cnt[i]*2;
}
printf("%d\n",res);
return 0;
} |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | java | import java.util.*;
public class Main {
Scanner in = new Scanner(System.in);
public static void main(String[] args) {
new Main();
}
public Main(){
new C().doIt();
}
class C{
int n,c;
ArrayList<Pair> list;
void doIt(){
n = in.nextInt();
c = in.nextInt();
list = new ArrayList<Pair>();
for(i... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | /*
* c.cc:
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functi... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const double EPS = 1e-9;
const int MOD = 1000000007;
int N, M;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> M;
vector<pair<int, int>> v;
for (int i = 0; i < (M); i++) {
int c, d;
cin >> c >> d;
v.push... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int N, M, ans = 0;
cin >> N >> M;
vector<int> data(N + 2);
for (size_t i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
if (b > a) {
data[a]++;
data[b + 1]--;
}
}
for (size_t i = 1; i < N + 2; i++) {
data[i] +=... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T>
ostream &operator<<(ostream &os, const ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
struct Mod {
long long int num;
Mod() : num(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) { ; }
operator long long int() { return num; }
};
Mod operator+(Mod a, Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator-(Mod ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, d, flg[1002] = {};
cin >> n >> d;
for (int i = 0; i < d; i++) {
int a, b;
cin >> a >> b;
flg[a] = max(flg[a], b);
}
int sta = 0, sum = 0, L, R;
for (int i = 0; i <= n; i++) {
if (flg[i] != 0 && sta == 1)
R = max(R, flg[i... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dfs(int n, vector<vector<int> >& adj) {
if ((int)adj[n].size() == 0) return n;
int ret = 0;
for (int i = 0; i < (int)adj[n].size(); i++) {
ret = max(ret, dfs(adj[n][i], adj));
}
return ret;
}
int main() {
int n, m;
cin >> n >> m;
vector<vector<int> >... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
using namespace std;
int main() {
int N, m;
cin >> N >> m;
vector<pair<int, int> > list(m), tmp;
for (int i = 0; i < (int)(m); i++) cin >> list[i].second >> list[i]... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, m, c, d;
vector<pair<int, int> > V;
cin >> N >> m;
for (int i = 0; i < m; i++) {
cin >> c >> d;
V.push_back(make_pair(c, d));
}
sort(V.begin(), V.end());
V.push_back(make_pair(1000000001, 1000000001));
for (int i = 0; i < V.size()... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int intervalState(int a, int b, int c, int d) {
if (a < c && b < c)
return 0;
else if (a > d && b > d)
return 1;
else if (a <= c && d <= b)
return 2;
else if (c < a && b < d)
return 3;
else if (a <= c && b < d)
return 4;
else if (c < a && d <... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const long long INF = 1107110711071107;
long long N, m;
vector<pair<long long, long long> > d;
long long dp[501][501][1001];
long long dfs(long long pre, long long now, long long n) {
if (n == m) {
return (now - pre + (N + 1) - pre);
}
if (dp[pre][now][n] >= 0) re... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T>
ostream &operator<<(ostream &os, const ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import static java.lang.Math.*;
public class Main {
class Pair implements Comparable<Pair> {
int a;
int b;
public Pair(int a, int b) {
this.a = a;
this.b = ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
signed main() {
int n, m;
cin >> n >> m;
vector<pair<int, int> > b(m);
for (int i = 0; i < m; i++) cin >> b[i].first >> b[i].second;
sort((b).begin(), (b).end());
vector<int> a(n + 2, 0);
for (auto e : b) {
a[e.first] += 1;
a[e.second + 1] += -1;
}
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
struct node {
int l;
int r;
} q[555];
bool cmp(node s1, node s2) {
if (s1.l == s2.l) return s1.r < s2.r;
return s1.l < s2.l;
}
int main() {
int n, m;
while (~scanf("%d%d", &n, &m)) {
memset(q, 0, sizeof(q));
for (int i = 0; i < m; i++) {
scanf("%d%... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
/**
* Shopping
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Str... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);
int n, m;
vector<pair<int, int> > constraint;
bool used[1000];
bool intersect(pair<int, int> lhs, pair<int, int> rhs) {
if (lhs.first <= rhs.first && rhs.first <= lhs.second) {
return true;
}
if ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int n, m, c, d, imos[1001];
int main() {
scanf("%d", &n);
scanf("%d", &m);
for (int i = 0; i < m; i++) {
scanf("%d", &c);
scanf("%d", &d);
imos[c--]++;
imos[d--]--;
}
int ret = n + 2, sum = 0;
for (int i = 0; i < n; i++) {
sum += imos[i];
if (sum > 0) ret += ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int N, M, ans = 0;
cin >> N >> M;
vector<int> data(N + 2);
for (size_t i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
if (b > a) {
data[a]++;
data[b + 1]--;
}
}
for (size_t i = 1; i < N + 2; i++) {
data[i] +=... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int n, m, c, d, imos[1001];
int main() {
scanf("%d", &n);
scanf("%d", &m);
for (int i = 0; i < n; i++) {
scanf("%d", &c);
scanf("%d", &d);
imos[c--]++;
imos[d--]--;
}
int ret = n + 2, sum = 0;
for (int i = 0; i < n; i++) {
sum += imos[i];
if (sum > 0) ret += ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
vector<int> vec[1010];
int a[1010], b[1010], vis[1010];
void dfs(int u) {
for (int i = 0; i < vec[u].size(); i++) {
int v = vec[u][i];
if (vis[v] == 0) {
vis[v] = 1;
dfs(v);
a[u] = max(a[u], a[v]);
}
}
}
int main() {
int n, m, u, v;
whi... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
struct Range{
int s,e;
Range(){}
Range(int s... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
using namespace std;
int main() {
int N, m;
cin >> N >> m;
vector<pair<int, int> > list(m), tmp;
for (int i = 0; i < (int)(m); i++) cin >> list[i].second >> list[i]... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
const long long MOD = 1e9 + 7;
long long sq(long long num) { return num * num; }
long long mod_pow(long long x, long long n) {
if (n == 0) return 1;
if (n == 1) return x % MOD;
long long res = sq(mod_pow(x, n / 2));
res %= MOD;
if (n % ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
int main() {
int N, m;
cin >> N >> m;
vector<int> backs(N, false);
for (int i = 0; i < m; ++i) {
int t, f;
cin >> t >> f;
t--;
f--;
for (i... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | public class Main{
public void run(java.io.InputStream in, java.io.PrintStream out){
java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
int n, m;
int[] c, d;
int i, j, k, tmp, ans, cmp;
n = sc.nextInt();
m = sc.nextInt();
c = new int[m];
d = new int[m];
ans = 0;
cmp ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int>, vector<pair<int, int> >,
greater<pair<int, int> > >
q;
long long int res = 0;
int main() {
int N, m;
cin >> N >> m;
int t = 1;
for (int i = 1; i <= m; i++) {
int c, d;
cin >> c >> d;
q.push(make_pair(c, d... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<pair<int, int> > ps(M);
for (int i = (0); i < (M); ++i) cin >> ps[i].first >> ps[i].second;
sort((ps).begin(), (p... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main() {
int i, j;
int d[1001];
for (i = 0; i <= 1000; ++i) {
d[i] = 0;
}
int n, m;
scanf("%d", &n);
for (i = 0; i <= n; ++i) {
d[i] = 1;
}
scanf("%d", &m);
int a, b;
for (i = 0; i < m; ++i) {
scanf("%d", &a);
scanf("%d", &b);
for (j = a; j < b; ++j... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
vector<pair<int, int>> R(M);
for (auto &i : R) cin >> i.first >> i.second;
sort(R.begin(), R.end());
int ans = 0, now = 0;
int c, d;
for (auto i = R.begin(); i != R.end();) {
c = i->first;
d = i->second;
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, c, d, l, r, flag, sum;
int V[1001] = {0};
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> c >> d;
V[c] = max(V[c], d);
}
l = r = -1;
flag = sum = 0;
for (int i = 0; i <= n; i++) {
if (r == i)
sum += 3 * (r - l) + ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
static const int INF = 1e9;
static const double PI = acos(-1.0);
static const double EPS = 1e-10;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T>
inline string toString(T x) {
ostringstream sout;
sout << x;
re... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const double EPS = 1e-9;
const int MOD = 1000000007;
int N, M;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> M;
vector<pair<int, int>> v;
for (int i = 0; i < (M); i++) {
int c, d;
cin >> c >> d;
v.push... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int n, q, a, b;
int x[100000], sum;
int main() {
cin >> n >> q;
for (int i = 0; i < q; i++) {
cin >> a >> b;
for (int j = a; j < b; j++) {
x[j] = 1;
}
}
for (int i = 0; i < n; i++) {
sum += 1 + x[i] * 2;
}
cout << sum << endl;
return 0;
}... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const long long INF = 1107110711071107;
long long N, m;
vector<pair<long long, long long> > d;
unordered_map<long long, long long> dp[1001][1001];
long long dfs(long long pre, long long now, long long n) {
if (n == m) {
return (now - pre + (N + 1) - pre);
}
if (dp... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000;
const int MAX_M = 500;
pair<int, int> rvs[MAX_M];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) cin >> rvs[i].first >> rvs[i].second;
sort(rvs, rvs + m);
int sum = 0, pci = -1, pdi = -1;
for (int i = 0; i < m; i++) {
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int>, vector<pair<int, int> >,
greater<pair<int, int> > >
q;
long long int res = 0;
int main() {
int N, m;
cin >> N >> m;
int t = 1;
for (int i = 1; i <= m; i++) {
int c, d;
cin >> c >> d;
q.push(make_pair(c, d... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import static java.lang.Math.*;
public class Main {
class Pair implements Comparable<Pair> {
int a;
int b;
public Pair(int a, int b) {
this.a = a;
this.b = ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | a[999],m,n,c;main(d){
for(scanf("%d%d",&n,&m);m--;)for(scanf("%d%d",&c,&d);c<d;c++)a[c]=1;
for(c=d=0;c<n;c++)d+=a[c]*2;
m=!printf("%d\n",d+n+1);
} |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int> > s;
for (int(i) = 0; (i) < (int)(m); ++(i)) {
int c, d;
scanf(" %d %d", &c, &d);
if (c < d) s.push_back(pair<int, int>(c, d));
}
sort((s).begin(), (s).end());
int ans = n + 1;
int back ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dfs(int n, vector<vector<int> >& adj) {
if ((int)adj[n].size() == 0) return n;
int ret = 0;
for (int i = 0; i < (int)adj[n].size(); i++) {
ret = max(ret, dfs(adj[n][i], adj));
}
return ret;
}
int main() {
int n, m;
cin >> n >> m;
vector<vector<int> >... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dfs(int n, vector<vector<int> >& adj) {
if ((int)adj[n].size() == 0) return n;
int ret = 0;
for (int i = 0; i < (int)adj[n].size(); i++) {
ret = max(ret, dfs(adj[n][i], adj));
}
return ret;
}
int main() {
int n, m;
cin >> n >> m;
vector<vector<int> >... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | a[999],n,m,c;main(d){
for(scanf("%d%d",&n,&m);m--;)for(scanf("%d%d",&c,&d);c<d;c++)a[c]=1;
for(c=d=0;c<n;c++)d+=a[c]*2;
m=!printf("%d\n",d+n+1);
} |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
struct ioi {
int l, r;
} seg[510];
int n, m;
bool intersect(ioi a, ioi b) {
if (a.l > b.l) swap(a, b);
if (b.l <= a.r)
return true;
else
return false;
}
ioi combine(ioi a, ioi b) {
a.l = min(a.l, b.l);
a.r = max(a.r, b.r);
return a;
}
int main() {
ci... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, m;
cin >> N >> m;
vector<int> shop(N);
for (int i = 0; i < (int)(m); ++i) {
int c, d;
cin >> c >> d;
shop[c - 1]++;
shop[d - 1]--;
}
int res = N + 1;
int cnt = 0;
int start = -1;
for (int i = 0; i < (int)(N); ++i) {
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
const unsigned long long inf = 1LL << 61;
const double eps = 1e-5;
using namespace std;
struct node {
int s, e;
} a[10000 + 5];
bool cmp(node a, node b) { return a.s < b.s; }
vector<node> v;
int main() {
int n, m;
while (cin >> n >> m) {
for (int i = 0; i < m; i++) cin >> a[i].s >> a[... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
struct rest {
int start, end;
inline void set(int a, int b) {
start = a;
end = b;
}
bool operator<(const rest &a) const { return end < a.end; }
} rests[600];
int n, m, restlen;
bool exist[600];
int main() {
int a, b;
while (scanf("%d%d", &n, &m) == 2) {
... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
const long long MOD = 1e9 + 7;
long long sq(long long num) { return num * num; }
long long mod_pow(long long x, long long n) {
if (n == 0) return 1;
if (n == 1) return x % MOD;
long long res = sq(mod_pow(x, n / 2));
res %= MOD;
if (n % ... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, m;
cin >> N >> m;
vector<bool> select(m, true);
vector<pair<int, int>> cd(m);
for (int i = 0; i < m; ++i) cin >> cd[i].first >> cd[i].second;
sort(cd.begin(), cd.end());
for (int i = 0; i < m; ++i) {
if (cd[i].second <= cd[i].first) sel... |
p00926 Shopping | Example
Input
10 3
3 7
8 9
2 5
Output
23 | {
"input": [
"10 3\n3 7\n8 9\n2 5"
],
"output": [
"23"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VVI = vector<VI>;
using PII = pair<ll, ll>;
const ll LLINF = (1LL << 60);
const ll INF = (1LL << 30);
const ll MOD = 1000000007;
template <typename T>
T &chmin(T &a, const T &b) {
return a = min(a, b);
}
template <typenam... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.