QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#871971#8623. Metaucup-team055#AC ✓1ms3712kbC++267.6kb2025-01-25 23:04:472025-01-25 23:04:52

Judging History

This is the latest submission verdict.

  • [2025-01-25 23:04:52]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 3712kb
  • [2025-01-25 23:04:47]
  • Submitted

answer

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
namespace{
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tuplis = array<ll, 3>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
const ll LINF=0x1fffffffffffffff;
const ll MINF=0x7fffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
const int MODD=998244353;
const ld DINF=INFINITY;
const ld EPS=1e-9;
const ld PI=3.14159265358979323846;
const ll dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const ll dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
#define overload5(a,b,c,d,e,name,...) name
#define overload4(a,b,c,d,name,...) name
#define overload3(a,b,c,name,...) name
#define rep1(n) rep2(_,n)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i=n;i--;)
#define rrep2(i,n) for(ll i=n;i--;)
#define rrep3(i,a,b) for(ll i=b;i-->(a);)
#define rrep4(i,a,b,c) for(ll i=(a)+((b)-(a)-1)/(c)*(c);i>=(a);i-=c)
#define rrep(...) overload4(__VA_ARGS__,rrep4,rrep3,rrep2,rrep1)(__VA_ARGS__)
#define each1(i,a) for(auto&&i:a)
#define each2(x,y,a) for(auto&&[x,y]:a)
#define each3(x,y,z,a) for(auto&&[x,y,z]:a)
#define each4(w,x,y,z,a) for(auto&&[w,x,y,z]:a)
#define each(...) overload5(__VA_ARGS__,each4,each3,each2,each1)(__VA_ARGS__)
#define all1(i) begin(i),end(i)
#define all2(i,a) begin(i),begin(i)+a
#define all3(i,a,b) begin(i)+a,begin(i)+b
#define all(...) overload3(__VA_ARGS__,all3,all2,all1)(__VA_ARGS__)
#define rall1(i) rbegin(i),rend(i)
#define rall2(i,a) rbegin(i),rbegin(i)+a
#define rall3(i,a,b) rbegin(i)+a,rbegin(i)+b
#define rall(...) overload3(__VA_ARGS__,rall3,rall2,rall1)(__VA_ARGS__)
#define sum(...) accumulate(all(__VA_ARGS__),0LL)
#define dsum(...) accumulate(all(__VA_ARGS__),0.0L)
#define Msum(...) accumulate(all(__VA_ARGS__),mint{})
#define elif else if
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type>name(__VA_ARGS__)
#define VEC(type,name,size) vector<type>name(size);in(name)
#define vv(type,name,h,...) vector name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector name(h,vector<type>(w));in(name)
#define vvv(type,name,h,w,...) vector name(h,vector(w,vector<type>(__VA_ARGS__)))
template<class T> ll sz(const T& a){ return size(a); }
template<class T, class U> ll count(const T& a, const U& b){ return count(all(a), b); }
template<class T, class F> ll count_if(const T& a, F b){ return count_if(all(a), b); }
template<class T, class F> void filter(T& a, F b){ a.erase(remove_if(all(a), not_fn(b)), a.end()); }
template<class T, class F = less<>> void sor(T& a, F b = F{}){ sort(all(a), b); }
template<class T> void rev(T& a){ reverse(all(a)); }
template<class T> void uniq(T& a){ sor(a); a.erase(unique(all(a)), end(a)); }
ll popcnt(ull a){ return __builtin_popcountll(a); }
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
template<class T> T div_floor(T a, T b) { return a / b - ((a ^ b) < 0 && a % b); }
template<class T> T div_ceil(T a, T b) { return a / b + ((a ^ b) > 0 && a % b); }
template<class T> bool chmin(T& a, const T& b){ return a > b ? a = b, 1 : 0; }
template<class T> bool chmax(T& a, const T& b){ return a < b ? a = b, 1 : 0; }
template<class T, class U> bool chmin(T& a, const U& b){ return a > b ? a = b, 1 : 0; }
template<class T, class U> bool chmax(T& a, const U& b){ return a < b ? a = b, 1 : 0; }
vector<ll> iota(ll n, ll begin = 0){ vector<ll> a(n); iota(a.begin(), a.end(), begin); return a; }
vector<pll> factor(ull x){ vector<pll> ans; for(ull i = 2; i * i <= x; i++) if(x % i == 0){ ans.push_back({i, 1}); while((x /= i) % i == 0) ans.back().second++; } if(x != 1) ans.push_back({x, 1}); return ans; }
vector<ll> divisor(ull x){ vector<ll> ans; for(ull i = 1; i * i <= x; i++) if(x % i == 0) ans.push_back(i); rrep(ans.size() - (ans.back() * ans.back() == x)) ans.push_back(x / ans[i]); return ans; }
template<class T> unordered_map<T, ll> press(vector<T> a){ uniq(a); unordered_map<T, ll> ans; rep(i, a.size()) ans[a[i]] = i; return ans; }
template<class T> auto run_press(const T& a){ vector<pair<decay_t<decltype(a[0])>, ll>> ans; each(x, a){ if(ans.empty() || ans.back().first != x) ans.emplace_back(x, 1); else ans.back().second++; } return ans; }
template<class... Ts> void in(Ts&... t);
[[maybe_unused]] void print(){}
template<class T, class... Ts> void print(const T& t, const Ts&... ts);
template<class... Ts> void out(const Ts&... ts){ print(ts...); cout << '\n'; }
namespace IO{
#define VOID(a) decltype(void(a))
struct S{ S(){ cin.tie(nullptr)->sync_with_stdio(0); fixed(cout).precision(12); } }S;
template<int I> struct P : P<I-1>{};
template<> struct P<0>{};
template<class T> void i(T& t){ i(t, P<3>{}); }
void i(vector<bool>::reference t, P<3>){ int a; i(a); t = a; }
template<class T> auto i(T& t, P<2>) -> VOID(cin >> t){ cin >> t; }
template<class T> auto i(T& t, P<1>) -> VOID(begin(t)){ for(auto&& x : t) i(x); }
template<class T, size_t... idx> void ituple(T& t, index_sequence<idx...>){ in(get<idx>(t)...); }
template<class T> auto i(T& t, P<0>) -> VOID(tuple_size<T>{}){ ituple(t, make_index_sequence<tuple_size<T>::value>{}); }
template<class T> void o(const T& t){ o(t, P<4>{}); }
template<size_t N> void o(const char (&t)[N], P<4>){ cout << t; }
template<class T, size_t N> void o(const T (&t)[N], P<3>){ o(t[0]); for(size_t i = 1; i < N; i++){ o(' '); o(t[i]); } }
template<class T> auto o(const T& t, P<2>) -> VOID(cout << t){ cout << t; }
template<class T> auto o(const T& t, P<1>) -> VOID(begin(t)){ bool first = 1; for(auto&& x : t) { if(first) first = 0; else o(' '); o(x); } }
template<class T, size_t... idx> void otuple(const T& t, index_sequence<idx...>){ print(get<idx>(t)...); }
template<class T> auto o(T& t, P<0>) -> VOID(tuple_size<T>{}){ otuple(t, make_index_sequence<tuple_size<T>::value>{}); }
#undef VOID
}
#define unpack(a) (void)(0 + ... + (a, 0))
template<class... Ts> void in(Ts&... t){ unpack(IO::i(t)); }
template<class T, class... Ts> void print(const T& t, const Ts&... ts){ IO::o(t); unpack(IO::o((cout << ' ', ts))); }
#undef unpack
#ifdef DEBUG
ll __lg(ull x){ return 63 - __builtin_clzll(x); }
#define debug(...) { print(#__VA_ARGS__); print(":"); out(__VA_ARGS__); }
#else
#define debug(...) void(0)
#endif
#define YESNO(yes,no) void yes(bool i = 1){ out(i?#yes:#no); } void no(){ out(#no); }
YESNO(first, second)
YESNO(First, Second)
YESNO(Yes, No)
YESNO(YES, NO)
YESNO(possible, impossible)
YESNO(Possible, Impossible)
YESNO(POSSIBLE, IMPOSSIBLE)


void solve(){
    LL(n);
    vector<ll>Q;
    rep(n){
        STR(s);
        VEC(ll,a,3);
        each(x,a)if(x==-1)x=LINF;
        Q.push_back(ranges::min(a));
    }
    sor(Q);
    ll sum=0;
    rep(i,n){
        sum+=Q[i];
        if(sum>300)return out(i);
    }
    out(n);
}
}
int main(){
    ll t = 1;
    // in(t); // マルチテストケースかどうか確認!
    rep(i,t){
        solve();
    }
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

13
AplusB -1 20 -1
TheBestWife 80 90 60
Cardinality 40 50 30
3D 40 -1 70
EqualStrings 25 15 20
FastTreeQueries 120 -1 40
GeoSharding 25 20 30
HaveYouSeenThisSubarray 80 90 60
InteractiveCasino 50 20 30
JigsawPuzzle 40 50 80
Knapsack -1 40 200
LondonUnderground -1 200 40
Meta 5 7 10

output:

10

result:

ok 1 number(s): "10"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

10
a 30 30 50
b 30 30 50
c 30 30 50
d 30 30 50
e 30 30 50
f 30 30 50
g 30 30 50
h 30 30 50
i 30 30 50
j 30 30 50

output:

10

result:

ok 1 number(s): "10"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

11
a 30 30 50
b 30 30 50
c 30 30 50
d 30 30 50
e 30 30 50
f 30 30 50
g 30 30 50
h 30 30 50
i 30 30 50
j 30 30 50
k 30 30 50

output:

10

result:

ok 1 number(s): "10"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

11
a 31 31 50
b 31 31 50
c 31 31 50
d 31 31 50
e 31 31 50
f 31 31 50
g 31 31 50
h 31 31 50
i 31 31 50
j 31 31 50
k 31 31 50

output:

9

result:

ok 1 number(s): "9"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1
a -1 -1 -1

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

1
A 300 300 -1

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

12
A 116 -1 36
B 67 106 -1
C 116 -1 15
D -1 -1 91
E 90 74 13
F -1 -1 -1
G 72 18 -1
H 80 -1 128
I 96 148 -1
J -1 82 111
K 77 -1 103
L 58 148 173

output:

7

result:

ok 1 number(s): "7"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

8
A 142 148 147
B -1 -1 -1
C -1 -1 -1
D -1 -1 -1
E -1 98 39
F -1 -1 52
G -1 215 -1
H 220 -1 -1

output:

3

result:

ok 1 number(s): "3"

Test #9:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

4
A 42 -1 37
B -1 -1 15
C -1 36 35
D -1 47 -1

output:

4

result:

ok 1 number(s): "4"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

14
A -1 21 82
B -1 -1 -1
C 81 197 -1
D -1 -1 -1
E -1 -1 -1
F 208 -1 182
G 212 -1 152
H -1 -1 105
I -1 -1 148
J 6 -1 46
K -1 -1 -1
L 191 -1 -1
M -1 36 51
N 48 -1 34

output:

6

result:

ok 1 number(s): "6"

Test #11:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

6
A -1 -1 44
B -1 21 2
C -1 21 -1
D 48 33 -1
E 44 -1 -1
F 35 15 9

output:

6

result:

ok 1 number(s): "6"

Test #12:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

6
A 134 124 22
B 5 28 72
C 77 100 41
D 130 137 96
E 0 150 30
F -1 38 -1

output:

6

result:

ok 1 number(s): "6"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

12
A 36 22 129
B 30 -1 -1
C -1 169 -1
D 43 -1 175
E -1 106 96
F -1 80 103
G 213 -1 -1
H 130 -1 240
I -1 201 -1
J -1 -1 -1
K -1 -1 101
L 130 129 118

output:

5

result:

ok 1 number(s): "5"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

4
A 36 -1 29
B 20 -1 49
C 11 -1 77
D -1 76 74

output:

4

result:

ok 1 number(s): "4"

Test #15:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

14
A -1 68 212
B 207 -1 -1
C -1 -1 217
D -1 -1 204
E -1 79 -1
F 67 101 226
G -1 236 217
H -1 -1 72
I 191 55 149
J -1 150 -1
K 41 51 -1
L 152 -1 -1
M 166 -1 174
N -1 -1 38

output:

5

result:

ok 1 number(s): "5"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

13
A 27 -1 114
B -1 -1 -1
C 48 -1 210
D 137 169 58
E -1 -1 136
F 154 156 -1
G 102 68 79
H 242 -1 234
I 145 -1 -1
J 190 -1 -1
K 33 246 194
L -1 -1 159
M -1 165 111

output:

5

result:

ok 1 number(s): "5"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

9
A 71 96 93
B -1 -1 20
C -1 -1 -1
D 41 -1 -1
E 83 -1 3
F -1 -1 14
G -1 35 -1
H -1 -1 -1
I 70 -1 -1

output:

7

result:

ok 1 number(s): "7"

Test #18:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

1
A 40 -1 81

output:

1

result:

ok 1 number(s): "1"

Test #19:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

7
A -1 -1 41
B 97 26 -1
C -1 49 92
D -1 69 -1
E 29 44 -1
F -1 -1 54
G 36 -1 50

output:

6

result:

ok 1 number(s): "6"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

7
A -1 142 53
B 93 54 37
C 95 79 -1
D -1 -1 -1
E -1 76 64
F 43 -1 -1
G -1 143 23

output:

6

result:

ok 1 number(s): "6"

Test #21:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

13
A -1 -1 76
B 272 -1 -1
C -1 73 148
D -1 224 231
E 143 -1 267
F 26 -1 182
G -1 84 -1
H 209 -1 260
I -1 -1 -1
J -1 182 145
K -1 -1 38
L -1 -1 -1
M 158 132 233

output:

5

result:

ok 1 number(s): "5"

Test #22:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

9
A 107 66 131
B -1 -1 39
C 113 6 94
D 92 34 119
E -1 -1 30
F 17 -1 -1
G 101 -1 -1
H -1 -1 60
I -1 -1 -1

output:

7

result:

ok 1 number(s): "7"

Test #23:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

1
A 159 -1 140

output:

1

result:

ok 1 number(s): "1"

Test #24:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1
A -1 -1 28

output:

1

result:

ok 1 number(s): "1"

Test #25:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

7
A -1 148 33
B -1 80 2
C 18 -1 -1
D 87 -1 -1
E 150 88 41
F -1 53 99
G 118 153 81

output:

6

result:

ok 1 number(s): "6"

Test #26:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

1
A -1 41 -1

output:

1

result:

ok 1 number(s): "1"

Test #27:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

11
A 1 152 -1
B -1 -1 -1
C -1 -1 50
D 61 -1 29
E 47 10 182
F -1 -1 24
G 134 -1 -1
H 28 99 69
I -1 -1 77
J 140 -1 -1
K -1 46 -1

output:

8

result:

ok 1 number(s): "8"

Test #28:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

3
A 24 -1 -1
B 2 -1 -1
C 23 -1 -1

output:

3

result:

ok 1 number(s): "3"

Test #29:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

13
A 61 39 -1
B 109 104 158
C -1 -1 97
D 22 80 -1
E -1 73 -1
F 3 123 -1
G -1 69 30
H -1 84 -1
I -1 124 152
J 92 -1 -1
K -1 -1 -1
L 157 -1 -1
M 86 109 -1

output:

6

result:

ok 1 number(s): "6"

Test #30:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

10
A -1 -1 -1
B 20 11 -1
C 19 -1 -1
D -1 -1 -1
E 17 -1 -1
F -1 11 27
G 4 -1 10
H -1 26 27
I 29 19 -1
J 28 -1 17

output:

8

result:

ok 1 number(s): "8"

Test #31:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

2
A -1 71 -1
B -1 43 150

output:

2

result:

ok 1 number(s): "2"

Test #32:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

12
A -1 -1 -1
B -1 -1 32
C 68 211 93
D -1 -1 85
E 33 -1 64
F -1 111 198
G -1 13 -1
H 177 50 77
I 31 -1 -1
J 36 20 3
K 14 -1 197
L 60 51 31

output:

9

result:

ok 1 number(s): "9"

Test #33:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

8
A 22 -1 -1
B -1 -1 -1
C -1 21 -1
D -1 11 28
E -1 14 61
F 62 49 -1
G 39 24 -1
H 18 6 60

output:

7

result:

ok 1 number(s): "7"

Test #34:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

4
A 168 143 -1
B -1 -1 136
C 116 67 105
D 41 10 47

output:

3

result:

ok 1 number(s): "3"

Test #35:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

10
A -1 -1 -1
B 27 51 -1
C -1 -1 -1
D 27 -1 11
E -1 28 -1
F 34 -1 -1
G -1 -1 43
H -1 16 7
I -1 43 -1
J -1 -1 19

output:

8

result:

ok 1 number(s): "8"

Test #36:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

12
A -1 30 -1
B -1 108 -1
C -1 70 82
D -1 31 65
E 79 120 -1
F 117 79 14
G -1 -1 31
H 114 -1 -1
I 113 11 -1
J -1 25 85
K -1 44 70
L -1 29 123

output:

9

result:

ok 1 number(s): "9"

Extra Test:

score: 0
Extra Test Passed