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 <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <func... |
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,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef pair<int,int> ii;
int N,m,par[1010];
int find(int x) {
if( x == par[x] ) return x;
return par[x] = find(par[x]);
}
void unit(int x,int y) {
x = find(x), y = find(y);
if( x != y ) par[x... |
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 <cstring>
using namespace std;
void solve()
{
cin.tie(0);
ios::sync_with_stdio(false);
bool needToMoveThreeTimes[1001];
memset(needToMoveThreeTimes, 0, sizeof(needToMoveThreeTimes));
int N, m;
cin >> N >> m;
for (int i = 0; i < m; ++i)
{
int c, d;
cin >> 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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, m; cin >> N >> m;
vector<int> F(N+1, 1);
for(int i = 0; i < m; ++i) {
int c, d; cin >> c >> d;
for(int j = c; j < d; ++j) F[j] = 3;
}
cout << accumulate(F.begin(), F.end(), 0) << 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": []
} | CORRECT | cpp | // ACM-ICPCアジア地区予選2014 C. Shopping
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int N, m;
while(cin >> N >> m){
vector< pair<int,int> > p(m);
for(int i=0;i<m;i++) cin >> p[i].first >> p[i].second;
sort(p.begin(), p.end());
int idx = 0;
int res = N+1;
while... |
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,a,b,ans=1;
int c[1001];
int main(){
scanf("%d %d",&n,&m);
for(int i=0;i<m;i++){
scanf("%d %d",&a,&b);
c[a]++;
c[b]--;
}
for(int i=1;i<=n;i++){
c[i]+=c[i-1];
ans+=(c[i]?3:1);
}
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 | cpp | #include<iostream>
#include<vector>
#include<algorithm>
#define f first
#define s second
#define inf 1000000001
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_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 <algorithm>
#include <iostream>
#include <vector>
#define push push_back
#define sz size()
#define s second
#define f first
using namespace std;
typedef pair<int,int> P;
int main(){
int N,m,c,d,ans=0;
vector<int> v2;
vector<P> v;
cin>>N>>m;
for(int i=0;i<m;i++) cin>>c>>d,v.push(make_pair(c,d));
so... |
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.Arrays;
import java.util.Scanner;
public class Main {
MyScanner sc = new MyScanner();
Scanner sc2 = new Scanner(System.in);
long start = System.currentTimeMillis();
long fin = System.currentTimeMillis();
final int MOD = 1000000007;
int[] dx = { 1, 0, 0, -1 };
int[] dy = { 0, 1, -1, 0 };
void ... |
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 <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#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<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main(int argc, char *argv[])
{
int n, m;
cin >> n >> m;
vector<pair<int,int>> cds;
for(int i = 0; i < m; i++) {
int c, d;
cin >> c >> d;
cds.push_back(make_pair(c,d)); // visits c after d (> c)
}
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"
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m; cin >> n >> m;
vector<int> imos(n + 10,0);
for (int i = 0; i < m; i++) {
int c, d; cin >> c >> d;
if (c < d) {
imos[c]++;
imos[d]--;
}
}
for (int i = 0; i < n; i++) {
imos[i + 1] += imos... |
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> st(N + 2);
for (int i = 0, c, d; i < m; i++) {
cin >> c >> d;
st[c]++;
st[d]--;
}
int res = N + 1;
for (int i = 1; i <= N; i++) {
st[i] += st[i - 1];
if (st[i]) {
res += 2;
}
}
cout << res << 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>
#define ALL(a) (a).begin(), (a).end()
#define llong long long
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(ALL(b));
vector<int> a(n+1,0);
for(auto e : b){
a[e.first] += 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": []
} | CORRECT | cpp | #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
using lint = long long;
using ldouble = long double;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> ps(m);
for (auto& p : ps) cin >> p.first >> p.second;
ps.emplace_back(n + 1, 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": []
} | CORRECT | java | import java.util.BitSet;
import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int N = sc.nextInt();
int M = sc.nextInt();
BitSet bs = new BitSet(N + 1);
for (int i = 0; i < M; ++i) {
int C = sc.nextInt();
int D = sc.nextInt(... |
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(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
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 "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
... |
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 _USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define repx(i, a, n) for(int i = a; i < n; i++)
#define loop while(1)
#define lli long long int
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queu... |
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<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb... |
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>
using namespace std;
int main(){
int n, m;
std::cin >> n >> m;
vector<bool> visit(n + 1, false);
for (int i = 0; i < m; i++) {
int l, r;
std::cin >> l >> r;
for (int j = l; j < r; j++) {
visit[j] = true;
}
}
int ans = n + 1;
for (int i = 0; i < vi... |
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;
scanf("%d %d", &N, &m);
int s[1024] = {0};
for (int i = 0; i < m; i++){
int a, b;
scanf("%d %d", &a, &b);
s[a]++;
s[b]--;
}
int ans = 0;
for (int i = 0; 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 | cpp | #include<bits/stdc++.h>
#include<string>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
#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 | cpp | #include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,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 | cpp | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const 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": []
} | CORRECT | cpp | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
int main(void) {
cin.tie(0); ios::sync_with_stdio(false);
int N,m; cin >> N >> m;
vector<int> c(m),d(m);
vector<int> flag(N+1);
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 | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,m;
cin >> N >> m;
vector<int> is(N+1,1);
for(int i=0; i<m; i++){ // 500
int c,d;
cin >> c >> d;
if(c < d)
for(int j=c; j<d; j++){ // 1000
is[j] = 3;
}
}
int ans = 0;
for(int i=0; i<=N; i++){
ans += is[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 | java | import java.io.*;
import java.util.*;
public class Main{
int N;
int M;
public void solve(){
N = nextInt();
M = nextInt();
int[] memo = new int[N + 1];
for(int i = 0; i < M; i++){
memo[nextInt()]++;
memo[nextInt()]--;
}
int ans = 0;
int cnt = 0;
for(int i = 0; i <= N; i++){
cnt += memo... |
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 <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define FOR(i,a,b) for (... |
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;
namespace {
template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
os << "[" << vs[0];
for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
return os << "]";
}
int N, M;... |
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 <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
ty... |
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 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdin.... |
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 | /**
In the name of Allah, the Most Gracious, the Most Merciful.
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
pair < int, int > ara[1005];
vector < pair < int, int > > ve;
int n, m, c, d, ans;
int main() {
#ifdef _OFFLINE_
freopen("in.txt", "r", stdin);
#... |
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 <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
... |
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 | //hikaku site donnyoku ni otosu ippanntekina teku
#include <iostream>
using namespace std;
int n, m;
int c[500], d[500];
int imos[1002];
int main() {
cin >> n >> m;
int i;
for (i = 0; i < n + 2; i++) imos[i] = 0;
for (i = 0; i < m; i++) {
cin >> c[i] >> d[i];
imos[c[i]]++;
imos[d[i]]--;
}
for (i = 1; 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 <vector>
#include <string>
#include <cstdlib>
#include <stack>
using namespace std;
int n,m;
int a[1050];
int main()
{
for (int i = 0; i < 1050; i++)
a[i]=-1;
cin>>n>>m;
for (int i = 0; i < m; i++){
int c,d;
cin>>c>>d;
a[c]=std::max(d,a[c]);
}
long long dist=0;
for (int i = 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 | cpp | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main() {
int n,m;
cin>>n>>m;
vector<int> rev(n+2);
REP(i,m) {
int c,d;
cin>>c>>d;
for(int j=c;j<d;++j) rev[j]=1;
}
cout<<(n+1+count(begin(rev),end(rev),1)*2)<<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": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
templ... |
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<vector>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
const int N = 1111;
int main(){
int n,k;
cin>>n>>k;
int masu[N]={0};
rep(i,k){
int a,b;
cin>>a>>b;
reps(j,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<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll... |
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())
again = set()
for i in range(m):
a,b = map(int, input().split())
for k in range(a,b):
again.add(k)
r = N+1 + 2*(len(again))
print(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 | python3 | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.... |
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<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using... |
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 long long long
using namespace std;
const int N=1e3;
const int inf=1e6;
int rq[N+2],mn,vis[N+2];
vector<int>adj[N+2];
void dfs(int node)
{
mn=min(mn,node);
if(vis[node])return ;
vis[node]=1;
for(auto x:adj[node])
dfs(x);
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(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 | cpp | #include <iostream>
#include <algorithm>
#define N 1001
using namespace std;
int main(){
int n,m,c,d,l,r,flag,sum;
int V[N]={0};
cin >> n >> m;
for(int i=0;i<m;i++) cin >> c >> d,V[c]=max(V[c],d);
l=r=flag=sum=0;
for(int i=0;i<=n;i++){
if(flag&&V[i]!=0) r=max(r,V[i]);
if(V[i]!=0&&!flag) l=i,r=V[i],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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<y;i++)
struct S {
int c, d;
};
int main()
{
int N, m;
cin >> N >> m;
vector<S> data(m);
rep(i, 0, m) {
cin >> data[i].c >> data[i].d;
}
while (true) {
bool flag = false;
rep(i, 0, m) {
... |
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>> cd(m);
int c, d;
for(int i = 0; i < m; i++){
cin >> c >> d;
cd[i] = make_pair(c, d);
}
sort(cd.begin(), cd.end());
int ans = N + 1;
int start = 0;
int end = 0;
for(int i = 0; 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>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
int main(){
int L, n;
while(cin >> L >> n) {
vector<pair<int, int>> vp(n);
REP(i, n) {
int a, b;
cin >> a >> b;
vp[i] = make_pair(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>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double>... |
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.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": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make... |
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>
using namespace std;
bool arr[1010];
int main(){
int N,M,c,d;
cin >> N >> M;
for(int i = 0 ; i < M ; i++){
cin >> c >> d;
for(int j = c ; j < d ; j++){
arr[j] = true;
}
}
cout << N+2*count(arr,arr+N,1)+1 << 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": []
} | CORRECT | cpp | #include "bits/stdc++.h"
using namespace std;
int rui[1010];
int main()
{
int n,m;
int ans=0;
cin>>n>>m;
ans+=n+1;
fill(rui,rui+1010,0);
for(int i=0;i<m;i++)
{
int c,d;
cin>>c>>d;
if(c<d)
{
rui[c]++;
rui[d]--;
}
}
for(int i=1;i<1010;i++)
rui[i]=rui[i]+rui[i-1];
//累積和が1以上の区間を見る
int i=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 | cpp | #include <bits/stdc++.h>
using namespace std;
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#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<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#includ... |
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>
#define PB push_back
using namespace std;
int main(void)
{
int vis[1024];
int n,m;
cin >> n >> m;
for(int i=0;i<n+5;++i) vis[i]=i;
for(int i=0;i<m;++i){
int left,right;
cin >> left >> right;
if(vis[left]<right)
vis[left]=right;
}
for(int i=0;i<n+5;++... |
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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] arg... |
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<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
//#include<>
using namespace std;
#define rep(i,j) for(i=0;i<j;(i)++)
int main()
{
int N,m;
cin >>N>>m;
int i;
pair<int,int> restricts[500],restricts_d_c[500];//(ci,di)と(... |
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 chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const ll MOD=1e9+7;
const ll INF=1e18;
int dx[]={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": []
} | CORRECT | cpp | #include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
using namespace std;
int n, m;
int l[505], r[505];
int dif[1005], sum[1005];
int main(void)
{
cin >> n >> m;
for(int i = 1; i <= m; i++) cin >> l[i] >> r[i];
for(int i = 1; i <= m; i++){
dif[l[i]]++, dif[r[i]]--;
}
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 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 <... |
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<algorithm>
using namespace std;
int main(){
// editorial解
// 重なる区間を1発で済ませてしまえば良いことが自明なので
// いもしてホイ
int n, m;
cin >> n >> m;
int imos[1005] = {};
for(int i = 0; i < m; i++){
int c, d;
cin >> c >> d;
imos[c]++, imos[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;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll ... |
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 argc, char *argv[]){
int n, m;
cin >> n >> m;
int c[m], d[m];
int road[n + 1];
memset(road, 0, sizeof(road));
for (int i = 0; i < m; i++) {
cin >> c[i] >> d[i];
for (int j = c[i]; j < d[i]; j++) {
road[j] = 1;
}
}
int ans = 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 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
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));
}
adj[n].clear();
return ret;
}
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 | // 3.3 ""
// https://onlinejudge.u-aizu.ac.jp/problems/2298
// 所要時間:
// 着席位置: 左前
// 学んだこと:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
int n, m;
cin >> n >> m;
vector<pair<int, int>> make;
for (int i = 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 | cpp | #include <stdio.h>
#pragma warning(disable : 4996)
int n, m, c, d, imos[1111];
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 + 1, sum = 0;
for (int i = 0; i < n; i++)
{
sum += imos[i];
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": []
} | CORRECT | cpp | // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1347
// ICPC: アジア地区予選2014C
// Shopping
/*
Problem.
スタート地点:0, ゴール地点: N+1であるとして、
地点1~Nに存在するN個あるノードを全て訪れるときの最短距離を求めよ、
ただし、M個の以下の内容の制約が与えられる。
- 制約(C, D):ノードCの前にノードDを訪れなければならない。
Point.
preceder[i]:iの最も後ろの先行ノード
- preceder[i]より前のiの先行ノードについては、
preceder[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;
int main()
{
int N, m;
cin >> N >> m;
bool th[1001] = {false};
for(int i = 0; i < m; i++) {
int c, d; cin >> c >> d;
for(int j = c; j < d; j++) th[j] = true;
}
int ans = N + 1;
for(int i = 0; i < N; i++) {
if(th[i]) ans += 2;
}
cout << 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 <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;
int main(){
int N,M,left,right,ans = 0;
scanf("%d %d",&N,&M);
bool* table = new bool[N+1];
for(int i = 0; i <= N; i++)table[i] = 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 | 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>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define im imag()
#define re real()
#define r(I, N) for(int I=0;I<N;I++)
#define f(I, A, B) for(int I=A;I<B;I++)
#define fd(I, A, B) for(int I=A;I>=B;I--)
#define ite(x) for(__typeof((x).begin()) it... |
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(void){
bool a[1001]={};
int N,m,cnt=0;
cin>>N>>m;
while(m--){
int c,d;
cin>>c>>d;//d???c?????????????????????
for(int i=c;i<d;++i)a[i]=true;//d??????c??????????????????
}
for(int i=0;i<=N;++i)if(a[i])cnt++;//?????£??... |
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 r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int n,m,x=0,q,w;
cin>>n>>m;
vector<int>a[n];
r(i,m)cin>>q>>w,
a[q-1].push_back(x),
a[w-1].push_back(x++);
set<int>s;int p=0,st,ans=0;
r(i,n){
if(a[i].size()){
if(!p)p++,st=i;
r(j,a[i].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": []
} | CORRECT | cpp | #include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
typedef long long ll;
using namespace std;
typedef vector<int> vi;
int N,m;
int c[505];
int d[505];
bool triple[1005];
int main()
{
memset(triple,false,sizeof(triple));
ll ans=0;
cin >> N >> m;
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": []
} | CORRECT | cpp | #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limit... |
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
#pragma comment (linker, "/STACK:526000000")
#include "bits/stdc++.h"
using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define ... |
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, c, d;
cin >> N >> m;
int imos[N+1];
fill(imos, imos+N+1, 0);
for(int i = 0; i < m; ++i){
cin >> c >> d;
++imos[c];
--imos[d];
}
int t = 0, ans = N+1;
for(int i = 0; i <= N; ++i){
t += imos[i];
if(t > 0) ans += 2;
}
co... |
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 <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 28;
int dp[510][1010];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
while(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 | #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++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 | java |
import java.io.*;
import java.util.*;
public class Main {
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
public void run() {
int n = in.nextInt(), m = in.nextInt();
int[] array = new int[n+1];
for (int i = 0; i < m; i++) {
int c = in.nextInt(), d = in.nextI... |
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 <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const dou... |
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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#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 <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp... |
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,a,b) for(int i=a;i<b;i++)
int main()
{
int N, M;
cin >> N >> M;
map< int, vector<int> > memo;
rep(i, 0, M)
{
int c, d;
cin >> c >> d;
memo[c].push_back(i);
memo[d].push_back(i);
}
ll ans = 0;
set<int> first, second;
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;
#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 | java |
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;
public class Main {
int INF = 1 << 28;
//long INF = 1L << 62;
double EPS = 1e-10;
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nex... |
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 FOR(i,bg,ed) for(int i=bg;i<ed;i++)
#define REP(i,n) FOR(i,0,n)
template<typename T>
bool chmax(T& l,T r){
bool ret = l<r;
if(l<r)l=r;
return ret;
}
template<typename T>
bool chmin(T& l,T r){
bool ret = l>r;
if(l>r)l=r;
return ret;
}
typedef ... |
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;
bool arr[1010] = {false};
cin >> N >> M;
for(int i = 0 ; i < M ; i++){
int c,d;
cin >> c >> d;
for(int j = c ; j < d ; j++){
arr[j] = true;
}
}
cout << N+2*count(arr,arr+N,true)+1 << 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": []
} | CORRECT | cpp | #include <iostream>
#include <algorithm>
#define N 1001
using namespace std;
int main(){
int n,m,c,d,l,r,flag,sum;
int V[N]={0};
cin >> n >> m;
for(int i=0;i<m;i++){
cin >> c >> d;
V[c]=max(V[c],d);
}
l=r=0;
flag=sum=0;
for(int i=0;i<=n;i++){
if(flag&&V[i]!=0) r=max(r,V[i]);
else if(flag... |
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 sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define pmod 1000000007
#define maxn 100005
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define INF 100... |
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 all(c) (c).begin(), (c).end()
int main() {
int N, m; cin >> N >> m;
vector<char> goback(N, 0);
while (m--) {
int c, d; cin >> c >> d;
fill_n(goback.begin() + c, d - c, 1);
}
cout << count_if(all(goback), [&](char c) { return 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 | #include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
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(... |
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;
int rev[1024]={};
int main(){
cin >> n >> m;
for(int i=0;i<m;++i){
int c,d;
cin >> c >> d;
rev[c]++;
rev[d]--;
}
for(int i=0;i<n;++i) rev[i+1]+=rev[i];
int answer=n+1;
for(int i=0;i<=n;++i) if(rev[i]) answer+=2;
cout << answer << 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": []
} | CORRECT | cpp | #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;
template<class T> constexpr T INF = ::nu... |
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 FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
typedef long long ll;
const int N = 1000;
const int M = 500;
int n, m;
int l[M], r[M];
int check[N+2];
int il[M], ir[M];
int main() {
int i, j;
scanf("%d%d ", &n, &m);
for (i=0; i<n; i++)
scanf("%d%d ", l+i, r+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>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.