Submission #19334710


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
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;}
//-------------------------------------------------------

int N;
ll C;
map<int,ll> M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>C;
	FOR(i,N) {
		cin>>x>>y>>r;
		M[x-1]+=r;
		M[y]-=r;
	}
	int pre=0;
	ll cur=0;
	ll sum=0;
	FORR(m,M) {
		sum+=(m.first-pre)*min(cur,C);
		pre=m.first;
		cur+=m.second;
	}
	cout<<sum<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task D - Snuke Prime
User kmjp
Language C++ (GCC 9.2.1)
Score 400
Code Size 1125 Byte
Status AC
Exec Time 286 ms
Memory 28568 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:21:8: warning: unused variable ‘j’ [-Wunused-variable]
   21 |  int i,j,k,l,r,x,y; string s;
      |        ^
./Main.cpp:21:10: warning: unused variable ‘k’ [-Wunused-variable]
   21 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:21:12: warning: unused variable ‘l’ [-Wunused-variable]
   21 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:44:38: note: in expansion of macro ‘FOR’
   44 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 6 ms 3568 KB
random_02.txt AC 2 ms 3656 KB
random_03.txt AC 2 ms 3512 KB
random_04.txt AC 3 ms 3520 KB
random_05.txt AC 3 ms 3584 KB
random_06.txt AC 2 ms 3620 KB
random_07.txt AC 2 ms 3580 KB
random_08.txt AC 2 ms 3500 KB
random_09.txt AC 2 ms 3576 KB
random_10.txt AC 2 ms 3660 KB
random_11.txt AC 2 ms 3620 KB
random_12.txt AC 2 ms 3456 KB
random_13.txt AC 2 ms 3520 KB
random_14.txt AC 2 ms 3460 KB
random_15.txt AC 2 ms 3520 KB
random_16.txt AC 63 ms 10440 KB
random_17.txt AC 122 ms 17508 KB
random_18.txt AC 106 ms 15536 KB
random_19.txt AC 105 ms 14644 KB
random_20.txt AC 259 ms 28404 KB
random_21.txt AC 167 ms 21508 KB
random_22.txt AC 25 ms 5880 KB
random_23.txt AC 286 ms 28512 KB
random_24.txt AC 275 ms 28568 KB
random_25.txt AC 54 ms 3508 KB
sample_01.txt AC 2 ms 3600 KB
sample_02.txt AC 2 ms 3660 KB
sample_03.txt AC 3 ms 3500 KB