QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#577673#7744. ElevatorzhangjiahaoCompile Error//C++142.9kb2024-09-20 13:59:022024-09-20 13:59:03

Judging History

你现在查看的是最新测评结果

  • [2024-09-20 13:59:03]
  • 评测
  • [2024-09-20 13:59:02]
  • 提交

answer

zhangjiahao 
登出
QOJ.ac
QOJ
 比赛
 Category
 题库
 提交记录
 Hack!
 PKUTS
搜索题库
ID	题目	提交者	结果	用时	内存	语言	文件大小	提交时间	测评时间
#271342	#7744. Elevator	Farmer_D	AC ✓	36ms	6800kb	C++14	1.9kb	2023-12-02 10:45:41	2023-12-02 10:45:42
Judging History
 你现在查看的是最新测评结果

[2023-12-02 10:45:42]评测
测评结果:AC用时:36ms内存:6800kb
 查看
[2023-12-02 10:45:41]提交
answer
#include <bits/stdc++.h>
#define F(i,x,y) for(int i=(x);i<=(y);i++)
#define DF(i,x,y) for(int i=(x);i>=(y);i--)
#define ms(x,y) memset(x,y,sizeof(x))
#define SZ(x) (int)x.size()-1
#define pb push_back
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int,int> pii;
template<typename T> void chkmax(T &x,T y){ x=max(x,y);}
template<typename T> void chkmin(T &x,T y){ x=min(x,y);}
#define int long long
template<typename T> void read(T &FF){
    FF=0;int RR=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') RR=-1;
    for(;isdigit(ch);ch=getchar()) FF=(FF<<1)+(FF<<3)+ch-48;
    FF*=RR;
}
const int N=100100;
int n,pref[N],k;
struct Bag{ int c,w,f;}bag[N];
void work(){
    read(n),read(k);
    F(i,1,n) read(bag[i].c),read(bag[i].w),read(bag[i].f);
    sort(bag+1,bag+n+1,[&](Bag o1,Bag o2){
        if(o1.f^o2.f) return o1.f<o2.f;
        return o1.w<o2.w;});
    int cur=0;
    F(i,1,n){ if(bag[i].w==1) cur=i;pref[i]=cur;}
    int ans=0,res=0,weight=bag[n].f;
    for(int i=n;i;i--){
        if(!bag[i].c) continue;
        if(!res) weight=bag[i].f;
        if(res+bag[i].w*bag[i].c>=k){
            int gt=(k-res)/bag[i].w;
            res+=gt*bag[i].w,bag[i].c-=gt;
            assert(res==k||res==k-1);
            if(res==k-1){
                assert(bag[i].w==2);
                while(pref[i]&&!bag[pref[i]].c) pref[i]=pref[pref[i]-1];
                if(pref[i]) bag[pref[i]].c--;
            }
            ans+=weight;
            int lef=bag[i].c*bag[i].w/k;
            ans+=lef*bag[i].f;
            bag[i].c-=lef*(k/bag[i].w);
            if(!bag[i].c) res=0;
            else weight=bag[i].f,res=bag[i].c*bag[i].w;
        }
        else res+=bag[i].w*bag[i].c;
    }
    if(res) ans+=weight;
    printf("%lld\n",ans);
}
signed main(){
    int T;read(T);
    while(T--) work();
    fprintf(stderr,"%d ms\n",int64_t(1e3*clock()/CLOCKS_PER_SEC));
    return 0;
}

源文件, 语言: C++14
这程序好像有点Bug,我给组数据试试? 

详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5708kb
Test #2:
score: 0
Accepted
time: 19ms
memory: 6748kb
Test #3:
score: 0
Accepted
time: 34ms
memory: 6784kb
Test #4:
score: 0
Accepted
time: 34ms
memory: 6800kb
Test #5:
score: 0
Accepted
time: 36ms
memory: 6776kb
Extra Test:
score: 0
Extra Test Passed
QOJ.ac | QOJ 4.4.25.0.dev
服务器时间: 2024-09-20 13:54:00 | 开源项目



Details

answer.code:13:9: error: "#" is not a valid filename
   13 | #271342 #7744. Elevator Farmer_D        AC ✓    36ms    6800kb  C++14   1.9kb   2023-12-02 10:45:41     2023-12-02 10:45:42
      |         ^
answer.code:13:44: error: extended character ✓ is not valid in an identifier
   13 | #271342 #7744. Elevator Farmer_D        AC ✓    36ms    6800kb  C++14   1.9kb   2023-12-02 10:45:41     2023-12-02 10:45:42
      |                                            ^
answer.code:88:6: error: stray ‘#’ in program
   88 | Test #1:
      |      ^
answer.code:93:6: error: stray ‘#’ in program
   93 | Test #2:
      |      ^
answer.code:98:6: error: stray ‘#’ in program
   98 | Test #3:
      |      ^
answer.code:103:6: error: stray ‘#’ in program
  103 | Test #4:
      |      ^
answer.code:108:6: error: stray ‘#’ in program
  108 | Test #5:
      |      ^
answer.code:116:14: error: too many decimal points in number
  116 | QOJ.ac | QOJ 4.4.25.0.dev
      |              ^~~~~~~~~~~~
answer.code:117:18: error: invalid digit "9" in octal constant
  117 | 服务器时间: 2024-09-20 13:54:00 | 开源项目
      |                  ^~
answer.code:1:1: error: ‘zhangjiahao’ does not name a type
    1 | zhangjiahao
      | ^~~~~~~~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:62,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:22:
/usr/include/c++/13/ext/type_traits.h:164:35: error: ‘constexpr const bool __gnu_cxx::__is_null_pointer’ redeclared as different kind of entity
  164 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/13/ext/type_traits.h:159:5: note: previous declaration ‘template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)’
  159 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/13/ext/type_traits.h:164:26: error: ‘nullptr_t’ is not a member of ‘std’; did you mean ‘nullptr_t’?
  164 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/13/cstddef:50,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:443:29: note: ‘nullptr_t’ declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
In file included from /usr/include/c++/13/bits/stl_pair.h:60,
                 from /usr/include/c++/13/bits/stl_algobase.h:64:
/usr/include/c++/13/type_traits:510:31: error: ‘std::size_t’ has not been declared
  510 |   template<typename _Tp, std::size_t _Size>
      |                               ^~~~~~
/usr/include/c++/13/type_traits:511:25: error: ‘_Size’ was not declared in this scope
  511 |     struct is_array<_Tp[_Size]>
      |                         ^~~~~
/usr/include/c++/13/type_traits:511:31: error: template argument 1 is invalid
  511 |     struct is_array<_Tp[_Size]>
      |                               ^
/usr/include/c++/13/type_traits:617:33: error: ‘nullptr_t’ is not a member of ‘std’; did you mean ‘nullptr_t’?
  617 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:443:29: note: ‘nullptr_t’ declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
/usr/include/c++/13/type_traits:617:33: error: ‘nullptr_t’ is not a member of ‘std’; did you mean ‘nullptr_t’?
  617 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:443:29: note: ‘nullptr_t’ declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
/usr/include/c++/13/type_traits:617:42: error: template argument 1 is invalid
  617 |     struct is_null_pointer<std::nullptr_t>
      |                                          ^
/usr/include/c++/13/type_traits:621:48: error: template argument 1 is invalid
  621 |     struct is_null_pointer<const std::nullptr_t>
      |                                                ^
/usr/include/c++/13/type_traits:625:51: error: template argument 1 is invalid
  625 |     struct is_null_pointer<volatile std::nullptr_t>
      |                                                   ^
/usr/include/c++/13/type_traits:629:57: error: template argument 1 is invalid
  629 |     struct is_null_pointer<const volatile std::nullptr_t>
      |                                                         ^
/usr/include/c++/13/type_traits:1348:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’?
 1348 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:214:23: note: ‘size_t’ declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~...